1.啟動kafka集群
在每台機器上啟動
bin/kafka-server-start.sh config/server.properties
2.檢視當前伺服器中的所有topic
bin/kafka-topics.sh --list --zookeeper zk01:2181
3.建立topic
bin/kafka-topics.sh --create --zookeeper mini1:2181 --replication-factor 1 --partitions 1 --topic ordermq
4.刪除topic
sh bin/kafka-topics.sh --delete --zookeeper zk01:2181 --topic test
需要server.properties中設定delete.topic.enable=true否則只是標記刪除或者直接重啟
5.通過shell命令傳送訊息
kafka-console-producer.sh --broker-list kafka01:9092 --topic ordermq
6.通過shell消費訊息
sh bin/kafka-console-consumer.sh --zookeeper mini1:2181 --from-beginning --topic ordermq
7.檢視消費位置
sh kafka-run-class.sh kafka.tools.consumeroffsetchecker --zookeeper zk01:2181 --group testgroup
8.檢視某個topic的詳情
sh kafka-topics.sh --topic test --describe --zookeeper zk01:2181
kafka常用命令
kafka常用操作命令 l檢視當前伺服器中的所有topic bin kafka topics.sh list zookeeper hadoop02 2181 l建立topic kafka topics.sh create zookeeper hadoop02 2181 replication fac...
kafka常用命令
啟動集群 nohup bin kafka server start.sh config server.properties 建立topic kafka topics topictt replication factor3 partitions3 create zookeeper hadoop1 21...
Kafka 常用命令
kafka console producer broker list 127.0.0.1 9092 topic mytopic kafka console consumer bootstrap server 127.0.0.1 9092 topic mytopic 建立主題,replication ...