topic列表

bin/kafka-topics.sh —zookeeper node101:2181 —list


创建topic

bin/kafka-topics.sh —zookeeper node101:2181,node102:2181,node103:2181 —create —replication-factor 1 —partitions 1 —topic topic_start


删除Topic

bin/kafka-topics.sh —zookeeper node101:2181,node102:2181,node103:2181 —delete —topic topic_start

删除topic时可能会遇到如下提示:

Topic topic_start is already marked for deletion.

并没有真正删除,如果要真正删除.
在每一台机器中的kafka/config/server.properties 文件加入 delete.topic.enable=true

最后所有机器重新启动kafka


生产消息

bin/kafka-console-producer.sh \ —broker-list node101:9092 —topic topic_start


消费消息

bin/kafka-console-consumer.sh \ —zookeeper node101:2181 —from-beginning —topic topic_start


查看topic详情

bin/kafka-topics.sh —zookeeper node101:2181 \ —describe —topic topic_start