Kafka命令行工具
查看Kafka现有的Topic
1
bin/kafka-topics.sh --zookeeper localhost:2181 --list
查看Topic详情
1
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic my-topic
配置Kafka现有的Topic的Partition
1
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic my-topic --partitions 3
清除Topic的数据
1 2
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic my-topic --config retention.ms=1000 bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic my-topic --delete-config retention.ms
删除Topic
1
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic my-topic
查看Topic的Offset
bin/kafka-run-class.sh kafka.tools.GetOffsetShell –broker-list localhost:9092 –topic my-topic查看Topic的消息数量
1
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic my-topic --time -1 --offsets 1 | awk -F ":" '{sum += $3} END {print sum}'
1
bin/kafka-console-consumer.sh config/consumer.properties --from-beginning --topic __consumer_offsets --bootstrap-server localhost:9092 --formatter "kafka.coordinator.gro