Step 1: 啓動服務器
首先啓動zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
(遠程啓動的時候需要在後面加上一個 & 作爲後臺進程,然後斷開和遠程的鏈接)
bin/zookeeper-server-start.sh config/zookeeper.properties &
接着啓動kafka服務器
bin/kafka-server-start.sh config/server.properties &
Step 2: 創建 一個 topic
bin/kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test
查看topicbin/kafka-topics.sh –list –zookeeper localhost:2181
Step 3: Send some messages
bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test
This is a message
This is another message
Step 4: 啓動一個客戶端(消費者)
bin/kafka-console-consumer.sh –zookeeper localhost:2181 –topic test –from-beginning
參考:http://www.cnblogs.com/qingyuuu/p/5844790.html
http://blog.csdn.net/tangdong3415/article/details/53432166