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