1. 程式人生 > >kafka單機安裝和啟動

kafka單機安裝和啟動

local 好的 sta config 後臺 rep 解壓 .sh sum

1.下載並解壓到/usr/local/src目錄下
技術分享圖片

2.運行kafka需要使用Zookeeper,先啟動Zookeeper,如果沒有Zookeeper,可以使用kafka自帶打包和配置好的Zookeeper

前臺運行:
bin/zookeeper-server-start.sh config/zookeeper.properties

後臺運行:
nohup bin/zookeeper-server-start.sh config/zookeeper.properties > zookeeper-run.log 2>&1 &

技術分享圖片

3.啟動kafka

前臺運行:
bin/kafka-server-start.sh config/server.properties

後臺運行:
nohup bin/kafka-server-start.sh config/server.properties > kafka-run.log 2>&1 &

技術分享圖片

4.創建topic

創建kafka topic:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

顯示kafka topic:
bin/kafka-topics.sh -list -zookeeper  localhost:2181

5.創建生產者和消費者

創建kafka生產者:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

創建kafka消費者:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

技術分享圖片
技術分享圖片

kafka單機安裝和啟動