查看当前服务器中的所有topic
bin/kafka-topics.sh --list --zookeeper amie01:2181
创建topic
bin/kafka-topics.sh --create --zookeeper amie01:2181 --replication-factor 3 --partitions 3 --topic myTopic
删除topic
sh bin/kafka-topics.sh --delete --zookeeper amie01:2181 --topic myTopic
需要server.properties中设置delete.topic.enable=true否则只是标记删除或者直接重启。
通过shell命令发送消息
kafka-console-producer.sh --broker-list amie01:9092 --topic myTopic
通过shell消费消息
sh bin/kafka-console-consumer.sh --zookeeper amie01:2181 --from-beginning --topic myTopic
查看消费位置
sh kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper amie01:2181 --group myGroup
查看某个Topic的详情
sh kafka-topics.sh --topic myTopic --describe --zookeeper amie01:2181
对分区数进行修改
kafka-topics.sh --zookeeper amie01:2181 --alter --partitions 15 --topic myTopic
查看topic 详细信息
kafka-topics.sh --describe --zookeeper amie01:2181 --topic myTopic