參考官網:http://kafka.apache.org/quickstart
kafka在使用之前必須先啟動zookeeper,但kafka的安裝包中都帶有zookeeper,是以小編沒有單獨下載下傳、安裝zookeeper。
kafka_2.11-1.0.0安裝包下載下傳位址:https://www.apache.org/dyn/closer.cgi?path=/kafka/1.0.0/kafka_2.11-1.0.0.tgz
1.解壓kafka安裝包。
2.啟動zookeeper
内置的zookeeper的配置檔案在kafka_2.11-1.0.0/config目錄下,一般不需要配置。
zookeeper的啟動指令在kafka_2.11-1.0.0/bin目錄下。
在kafka_2.11-1.0.0目錄下輸入啟動指令
出現下面界面代表啟動成功,注意不是卡住了,我就是以為卡住了,找了一下午的問題。。。。。
3.啟動kafka
bin/kafka-server-start.sh config/server.properties
出現下面界面代表啟動成功
4.建立topic
5.發送測試資訊(生産者)
bin/kafka-console-consumer.sh --bootstrap-server localhost: --topic test --from-beginning
//彈出“>”符号後輸入下面兩行測試資訊
This is a message
This is another message
6.接收資訊(消費者)
7.接收到下列資訊代表成功
This is a message
This is another message