1)檢視當前伺服器中的所有topic
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper
hadoop102:2181 --list
2)建立topic
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper
hadoop102:2181 --create --replication-factor 3 --partitions 1
--topic first
選項說明:
–topic 定義topic名
–replication-factor 定義副本數
–partitions 定義分割槽數
3)刪除topic
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper
hadoop102:2181 --delete --topic first
4)傳送訊息
[atguigu@hadoop102 kafka]$ bin/kafka-console-producer.sh
--broker-list hadoop102:9092 --topic first
hello worldatguigu atguigu
5)消費訊息
[atguigu@hadoop102 kafka]$ bin/kafka-console-consumer.sh \
--bootstrap-server hadoop102:9092 --topic first
[atguigu@hadoop102 kafka]$ bin/kafka-console-consumer.sh \
--bootstrap-server hadoop102:9092 --
from
-beginning --topic first
–from-beginning:會把主題中現有的所有的資料都讀取出來。
6)檢視某個topic的詳情
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh
--zookeeper hadoop102:2181 --describe –
-topic first
7)修改分割槽數
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh
--zookeeper hadoop102:2181 --alter –-
topic first --partitions 6
Kafka命令列操作
1 檢視當前伺服器中的所有topic atguigu hadoop102 kafka bin kafka topics.sh zookeeper hadoop102 2181 list2 建立topic atguigu hadoop102 kafka bin kafka topics.sh zook...
Kafka 命令列操作
1.檢視當前伺服器中的所有 topic bin kafka topics.sh zookeeper localhost 2181 list2.建立 topic bin kafka topics.sh zookeeper localhost 2181 create replication factor...
Kafka命令列操作
1.檢視當前伺服器中的所有topicbin kafka topics.sh zookeeper bigdata13 2181 list2.建立topicbin kafka topics.sh zookeeper bigdata13 2181 create replication factor 3 p...