下載地址
https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.4.0/kafka_2.11-2.4.0.tgz
1.解壓到本地目錄
我的路徑是 C:\Mysoftware\02Dev\kafka_2.11-2.4.0
2.啓動 kafka 服務
- win+r 打開cmd
cd C:\Mysoftware\02Dev\kafka_2.11-2.4.0
2.啓動zookeeper
服務
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
3.啓動kafka
服務
bin\windows\kafka-server-start.bat config\server.properties
創建Topic
1.創建Topic,名稱爲 test
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看已創建的 Topic
bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
測試
生產者
bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
消費者
bin\windows\kafka-console-consumer.bat --bootstrap-server 127.0.0.1:9092 --topic test--from-beginning
以上命令非後臺啓動,需要單獨開啓一個cmd 命令行窗口
###########################################
阿里雲部署單機版 需要添加外網訪問
vim config/server.properties
broker.id=0
port=9092
host.name=阿里雲內網地址
advertised.host.name=阿里雲外網映射地址