1)檢視 kafka topic 列表
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper
hadoop102:2181/kafka --list
2)建立 kafka topic
進入到/opt/module/kafka/目錄下建立日誌主題
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper
hadoop102:2181,hadoop103:2181,hadoop104:2181/kafka --create –
replication-factor 1 --partitions 1 --topic topic_log
3)刪除 kafka topic
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --delete –
zookeeper hadoop102:2181,hadoop103:2181,hadoop104:2181/kafka -
-topic topic_log
4)kafka 生產訊息
[atguigu@hadoop102 kafka]$ bin/kafka-console-producer.sh
–broker-list hadoop102:9092 --topic topic_log
5)kafka 消費訊息
[atguigu@hadoop102 kafka]$ bin/kafka-console-consumer.sh
–bootstrap-server hadoop102:9092 --from-beginning --topic
topic_log
–from-beginning:會把主題中以往所有的資料都讀取出來。根據業務場景選擇是否增加
6)檢視 kafka topic 詳情
[atguigu@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper
hadoop102:2181/kafka
–describe --topic topic_log
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 ...