新版kafka在windows下的安装使用
所需环境jdk1.8(1.8的某些低版本用不了,kafka启动会报错)
1.下载kafka
选个高版本即可,这里选的是2.8.0
打开文件夹,点击下载
完毕后,解压
在此目录下打开cmd
2.启动zk
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
3.同样方式打开一个cmd窗口,启动kafka
bin\windows\kafka-server-start.bat config\server.properties
如果kafka启动中断,可能是本机的java8版本问题,
在这里提供了java1.8.0_241,选择windows-x64.exe即可
提取码:0262
创建主题
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看主题
bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
创建生产者
bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
另外打开一个cmd窗口,创建消费者
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
在生产者页面输入消息,消费者同步接收消息,完工