Kafka常用指令

工作中经常会用到的指令
 
 1 # 查询topic为test的partition数量 
 2 ./kafka-topics.sh --zookeeper localhost:2181/kafka --topic test --describe
 3 
 4 
 5 # 查看kafka上所有的topic 
 6 ./kafka-topics.sh --zookeeper localhost:2181/kafka --list 
 7 
 8 
 9 # 发送消息 
10 ./kafka-console-producer.sh --broker-list localhost:9092 --topic test 
11 
12 
13 # 收取消息 
14 ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning 
15 
16 
17 # 修改topic为test的partition数量(只能越修改越大) 
18 ./kafka-topics.sh --zookeeper localhost:2181 --alter --topic test --partitions 8
19 
20 
21 # 创建名为test的topic
22 ./kafka-topics.sh --create --zookeeper localhost:2181 --topic test --replication-factor 1 --partition 4
23 
24 
25 # 删除为test的topic
26 ./kafka-topics.sh --delete --zookeeper localhost:2181 --topic test 
27 
28 
29 # 查看所有的group
30 ./kafka-run-class.sh kafka.admin.ConsumerGroupCommand --zookeeper localhost:2181 --list
31 
32 
33 # 查看数据是否消费完成 
34 ./kafka-run-class.sh kafka.admin.ConsumerGroupCommand --zookeeper localhost:2181 --describe --group testGroup
原文地址:https://www.cnblogs.com/pinxiong/p/6760538.html