Kafka:常用命令
生活随笔
收集整理的這篇文章主要介紹了
Kafka:常用命令
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
- 啟動(dòng)Kafka:kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
- 創(chuàng)建一個(gè)叫test的話題,有兩個(gè)分區(qū),每個(gè)分區(qū)3個(gè)副本:kafka-topics.sh --zookeeper localhost:2181 --create --topic test --replication-factor 3 --partitions 2
- 查看創(chuàng)建的topic:kafka-topics.sh --zookeeper localhost:2181 --list
- 查看所有話題的詳細(xì)信息:kafka-topics.sh --zookeeper localhost:2181 --describe
- 列出指定話題的詳細(xì)信息:kafka-topics.sh --zookeeper localhost:2181 --describe --topic test
- 刪除一個(gè)話題:kafka-topics.sh --zookeeper localhost:2181 --delete --topic test
- 生產(chǎn)消息:kafka-console-producer --broker-list localhost:9092 --topic test1
- 消費(fèi)消息: kafka-console-consumer --bootstrap-server localhost:9092 --topic test1 --from-beginning加了–from-beginning 重頭消費(fèi)所有的消息,不加–from-beginning 從最新的一條消息開始消費(fèi)
- 查看某個(gè)topic對應(yīng)的消息數(shù)量:kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test --time -1
- 顯示所有消費(fèi)者:kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
- 獲取正在消費(fèi)的topic(console-consumer-63307)的group的offset:kafka-consumer-groups.sh --describe --group console-consumer-63307 --bootstrap-server localhost:9092
- 停止Kafka:kafka-server-stop.sh
總結(jié)
以上是生活随笔為你收集整理的Kafka:常用命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis(五):List集合数据类型详
- 下一篇: Shell脚本——数字计算