Kafka + zookeeper download/install/use (super detailed)

Kafka needs zk to support. So download zk first

1. Download and install zookeeper

download link

Choose without source

Insert picture description here
Insert picture description here

Download and unzip 2 times

Insert picture description here

Go to the D:\zookeeper\apache-zookeeper-3.6.1-bin\conf directory and rename zoo_sample.cfg to zoo.cfg

Modify zoo.cfg

Insert picture description here

Data files will be generated here
Insert picture description here

Add ZK environment variables

Insert picture description here
Insert picture description here

ZK is now configured. You can start ZK

Insert picture description here

Or open cmd and enter zkserver
Insert picture description here

Prompt this startup is successful!
Insert picture description here

2. Download and install kafka

download link
Insert picture description here

Download the latest version
Insert picture description here

After downloading, decompress, you have to decompress twice
Insert picture description here

Enter: D:\kafka\kafka_2.12-2.5.0\config

Modify server.properties

Insert picture description here

Go to the D:\kafka\kafka_2.12-2.5.0 directory and execute.\bin\windows\kafka-server-start.bat .\config\server.properties
Insert picture description here

Kafka started successfully!

Insert picture description here

Test use

Do not close zk and Kafka that has just been started.
Create topic and
enter the windows directory of
Kafka to execute the following command. 2181 is the zookeeper port kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1- -topic demo
Insert picture description here

Create topic successfully!
Start two more windows, one consumer and one producer,
and enter into the windows directory of Kafka to execute the following commands. 9092 is the port
producer of Kafka : kafka-console-producer.bat --broker-list localhost:9092 --topic demo
consumer:kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic demo --from-beginning
Insert picture description here
Insert picture description here

4 services started:
Insert picture description here

You can enter the content at will in the producer service window, and the consumer service window will receive it. At this point, the test is complete, and the test result is OK!
Welcome to leave comments and learn together!!! Thanks!!!

===========================
Original article, reprinted with the source!

Guess you like

Origin blog.csdn.net/dayonglove2018/article/details/106919643