查询topic 列表信息
前提是需要进入到kafka的目录
Linux
目录 \kafka_2.12-2.8.0\bin\
sh kafka-topics.sh --list --zookeeper localhost:2181
windows
目录 \kafka_2.12-2.8.0\bin\windows
kafka-topics.bat --list --zookeeper localhost:2181
window下执行截图
查看topic的详细情况
linux
./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
windows
kafka-topics.bat --describe --zookeeper localhost:2181 --topic topic.test
返回结果信息(基本topic信息和分区信息)
更改top分区数量,只能增加不能减少
linux
./kafka-topics.sh --alter --zookeeper localhost:2181 --topic test --partitions 5
windows
kafka-topics.bat --alter --zookeeper localhost:2181 --topic topic.test --partitions 9
效果图
查看topic的消息列表
linux
sh kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topicName --from-beginning
window
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic topic.test --from-beginning
window执行结果截图