中间件:Win10安装运行Kafka

一、JDK环境安装配置

可参考:百度安全验证

二、Zookeeper安装配置

 1、下载  : Index of /dist/zookeeper/zookeeper-3.4.9

 

 2、解压到本地,目录不要带中文符号,保证纯英文

 3、zoo.cfg修改

 4、cmd运行,使用命令zkServer 

三、Kafka安装

1、下载:Apache Kafka

2、配置文件 kafka_2.12-0.11.0.0\config  server.properties

默认在9092端口上运行,并连接zookeeper的默认端口:2181

可修改  zookeeper.connect=localhost:2181

3、启动kafka

指定配置文件CMD启动:   .\bin\windows\kafka-server-start.bat .\config\server.properties

四、测试

1、创建主题

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

2、查看主题

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

3、创建生产者,消费者,使用主题 test_demo,生产者推送消息,消费者订阅成功

 生产者:  .\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test_demo

消费者:.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 -topic test_demo --from-beginning

猜你喜欢

转载自blog.csdn.net/chenyang_wei/article/details/128536246