kafka安裝完成啟動後,測試連不起來,發現版本比以前高,他們的語法有點變化,zookeeper這個語法被淘汰掉了,因為新版本不存放offset在zk上了。使用–bootstrap-server來指定broker的位置
檢視所有topic
kafka-topics --list --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092
生產者
kafka-console-producer --broker-list hadoop1:9092,hadoop2:9092,hadoop3:9092 --topic tp_label
消費者
kafka-console-consumer --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --topic tp_label
消費者-從頭消費資料
kafka-console-consumer --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --from-beginning --topic tp_label
檢視topic主題詳細資訊
kafka-topics --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --topic tp_label --describe
檢視消費者組
kafka-consumer-groups --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --list
檢視指定消費者組詳細資訊(consumer-id host client-id partitions assignment)
kafka-consumer-groups --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --group cloudera_mirrormaker --describe --members --verbose
consumer-id host client-id #partitions assignment
cloudera_mirrormaker-0-1d1a8103-3e9d-43c4-9a34-09f677fd049a /10.130.210.246 cloudera_mirrormaker-0 0 -
cloudera_mirrormaker-0-a6168ff9-e579-4536-b92a-fc6aaf82b8c1 /10.130.210.245 cloudera_mirrormaker-0 0 -
cloudera_mirrormaker-0-a110eabd-5191-49a0-acf4-dbdc7e9a602f /10.130.210.247 cloudera_mirrormaker-0 0 -
檢視指定消費者組詳細資訊(consumer-id host client-id partitions)
kafka-consumer-groups --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --group cloudera_mirrormaker --describe --members
//consumer-id host client-id #partitions
//cloudera_mirrormaker-0-1d1a8103-3e9d-43c4-9a34-09f677fd049a /10.130.210.246 cloudera_mirrormaker-0 0
//cloudera_mirrormaker-0-a6168ff9-e579-4536-b92a-fc6aaf82b8c1 /10.130.210.245 cloudera_mirrormaker-0 0
//cloudera_mirrormaker-0-a110eabd-5191-49a0-acf4-dbdc7e9a602f /10.130.210.247 cloudera_mirrormaker-0 0
檢視指定消費者組詳細資訊(topic partition current-offset log-end-offset lag consumer-id host client-id)
kafka-consumer-groups --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --group cloudera_mirrormaker --describe
//topic partition current-offset log-end-offset lag consumer-id host client-id
//***_trajectory 0 143693805 143693905 100 consumer-1-02f47385-5496-4094-9513-09c0b66b47bc /59.202.28.243 consumer-1
//***_trajectory 1 137186261 137186348 87 consumer-1-02f47385-5496-4094-9513-09c0b66b47bc /59.202.28.243 consumer-1
檢視指定消費者組詳細資訊(coordinator(id) assignment-strategy state members)
kafka-consumer-groups --bootstrap-server hadoop1:9092,hadoop2:9092,hadoop3:9092 --group cloudera_mirrormaker --describe --state
//coordinator (id) assignment-strategy state #members
//hadoop3:9092 (63) range stable 3
Kafka基礎 命令列使用舉例 CDH版本
kafka的命令列 共有10個命令,每個命令有各自的作用 常用的命令 kafka console consumer kafka console producer kafka topics和kafka run class 1 建立topic kafka topics create topic your...
kafka命令 Kafka命令列簡單使用
建立主題 kafka topics.sh create zookeeper 172.16.48.163 2181 kafka replication factor 2 partitions 1 topic test9999 replication factor 該主題每個分割槽的副本數,不能大於br...
kafka 命令列表
kafka 基於0.8.0版本的命令用法 檢視topic分布情況kafka list topic.sh bin kafka list topic.sh zookeeper 192.168.197.170 2181,192.168.197.171 2181 列出所有topic的分割槽情況 bin ka...