Installing Zookeeper
Kafka operation requires a jdk+zookeeper environment to be able to use, JDK installation and environment variable configuration is not introduced here, you need to install zookeeper. Can be downloaded from the official website Https://www.apache.org/dyn /closer.cgi/zookeeper/
Unzip the downloaded package and change the zoo_sample.cfg to zoo.cfg in the Conf directory.
After opening zoo.cfg will change the path of the datadir inside, I change here to the following
Datadir=e:\\data\\logs\\zookeeper
The zookeeper is then fitted to the environment variable, and its configuration is similar to the JDK configuration
Run zookeeper, the cmd inside the input zkserver will appear below is the installation success
Installing Kafka
Kafka:http://kafka.apache.org/downloads
Unzip the downloaded installation package and go to the Conf directory to find the Server.properties file
Find and edit
Log.dirs=e:\\data\\logs\\kafka
zookeeper.connect=localhost:2181
Then go to the Kafka directory to execute the following command, you can use the blank space in the folder to press SHIFT and right -click to Open the command window
. \bin\windows\kafka-server-start.bat. \config\server.properties
?
Every time you run Kafka, you have to turn this and the zkserver on.
You can then test to create a topic
. \bin\windows\kafka-topics.bat--create--zookeeper localhost:2181--replication-factor 1--partitions 1--topic test
After opening the producer, go to the Bin/windows directory using the command window
. \kafka-console-producer.bat--broker-list localhost:9092--topic test
Open the consumer and go to the Bin/windows directory using the command window
. \kafka-console-consumer.bat--zookeeper localhost:2181--topic test
After that, you can enter some information at the Producer's window, and then you can see the input information on the consumer's side.
Install Kafka on window