1、啟動zookeeper
cd $ZK_HOME/bin
./zkServer.sh start
jps : QuorumPeerMaiin
Prot : 2181
2、啟動kafka
(1)啟動
cd $KAFKA_HOME/bin
./kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
jps : Kafka
端口 : 9092
3、建立topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test-topic-180216-01
4、測試是否正常
(1)起一個發送消息
kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic-180216-01
(2)起一個消費消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic-180216-01
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
說明:--from-beginning 每次都從頭消費
# 老的寫法
kafka-console-consumer.sh --zookeeper localhost:2181 --topic test-topic-180216-01
5、檢視topic資訊
檢視描述
kafka-topics.sh --describe --zookeeper localhost:2181
檢視所有topic
kafka-topics.sh --list --zookeeper localhost:2181
根據topic名稱檢視内容
kafka-topics.sh --describe --zookeeper localhost:2181 --topic test-topic-180216-01
版權聲明:本文為CSDN部落客「weixin_34190136」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。
原文連結:https://blog.csdn.net/weixin_34190136/article/details/92409337