Kafka的运行依赖于Zookeeper,所以在运行Kafka之前我们需要安装并运行Zookeeper
1)ZOOKEEPER_HOME:D:\machine\kafka_2.11-1.1.0
2)Path: 在现有的值后面添加";%ZOOKEEPER_HOME%\bin;"
打开cmd然后执行zkserver
https://www.apache.org/dyn/closer.cgi?path=/kafka/1.1.0/kafka_2.11-1.1.0.tgz
.\bin\windows\kafka-server-start.bat .\config\server.properties
启动过程报错,参考此链接:https://blog.csdn.net/weixin_44100514/article/details/88413870 可解决
(1)Producer
进入目录D:\machine\kafka_2.11-1.1.0\bin\windows输入如下命令:
kafka-console-producer.bat --broker-list localhost:9092 --topic testDemo
(2)Consumer
进入目录D:\machine\kafka_2.11-1.1.0\bin\windows输入如下命令:
kafka-console-consumer.bat --zookeeper localhost:2181 --topic testDemo
然后就可以在Producer中发信息,在Consumer中收信息了
参考链接: 1、https://www.cnblogs.com/mh-study/p/9537970.html 2、https://blog.csdn.net/tiantangdizhibuxiang/article/details/80556064