1.下载
Kafka 官网下载链接:https://kafka.apache.org/downloads
下载后解压
2.启动服务
需遵循以下几步, 依次打开新的命令行启动, 也不要关闭之前的命令行窗口
cmd 至 解压目录(注意目录不要太长,不然后面执行会说命令行太长)
启动 Zookeeper 服务, 默认端口 2181
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
1
启动 Kafka 服务,默认端口 9092
bin\windows\kafka-server-start.bat config\server.properties
其他启动:
.\bin\windows\kafka-server-start.bat .\config\server.properties
.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 2 --topic test
.\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
.\bin\windows\kafka-topics.bat --describe --zookeeper localhost:2181 --topic test
.\bin\windows\kafka-topics.bat --delete --zookeeper localhost:2181 --topic test
.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test
.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning