Setting up the Kafka environment (Windows)

1. Install JDK

2. Install Zookeeper 
The operation of Kafka depends on Zookeeper, so before running Kafka we need to install and run Zookeeper 
 2.1 and download the installation file (zookeeper-3.4.9): http://mirror.bit.edu.cn/apache/zookeeper /
 2.2. Unzip zookeeper-3.4.9 (unzip to E:\develop\Kafka\zookeeper-3.4.9) 
 2.3. Open zookeeper-3.4.9\conf, rename zoo_sample.cfg to zoo.cfg 
 2.4, modify zoo .cfg configuration file:


 2.5. Run Zookeeper, enter the zookeeper-3.4.9\bin directory, double-click zkServer.cmd, and
if the following information is printed, it means that zookeeper has been successfully installed and is running on port 2181


 

3, cheap Kafka

 

 3.1. Kafka download address http://kafka.apache.org/downloads.html, after downloading, extract it to E:\develop\Kafka\kafka_2.12-1.0.0

 3.2. Configure the server.properties file (E:\develop\Kafka\kafka_2.12-1.0.0\config\server.properties), Kafka will follow the default,

Run on port 9092 and connect to zookeeper's default port: 2181
   3.2.1, log.dirs=E:/develop/Kafka/kafka_2.12-1.0.0/tmp/kafka-logs
   3.2.2, zookeeper.connect= localhost:2181
4. Start Kafka (before starting the Kafka server, make sure the Zookeeper instance is ready and running)

 4.1. Start the server, run the cmd command window, do not close the window after the startup is successful

.\bin\windows\kafka-server-start.bat .\config\server.properties

 


 

 

4.2. Create a theme, run a cmd command window, and do not close the window after the creation is successful

.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic kftest01

 

 

View topics

.\bin\windows\kafka-topics.bat -zookeeper localhost:2181 --list  
kftest01  

 

delete topic

.\bin\windows\kafka-topics.bat --delete --zookeeper localhost:2181 --topic kftest01  
Topic kf_test_01 is marked for deletion.  
Note: This will have no impact if delete.topic.enable is not set to true.  

 

 

4.3. Create a producer, run the cmd command window, and do not close the window after the creation is successful

 

.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic kftest01 

 

 

 

4.4、创建消费者,进行cmd命令窗口,创建成功后不要关闭窗口

 

.\bin\windows\kafka-console-consumer.bat --zookeeper localhost:2181 --topic kftest01

 

5、测试

 


 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326568704&siteId=291194637