# 创建一个topic
kafka-topics.sh --zookeeper localhost:2181 --create --topic <name of your topic> --partitions <number-of-partitions> --replication-factor <number-of-replication>
Describe a topic.
# 描述一个topic
kafka-topics.sh --zookeeper localhost:2181 --describe --topic <name of your topic>
List all the topics.
# 列出所有的话题
kafka-topics.sh --zookeeper localhost:2181 --list
Produce messages:
# 产生信息
kafka-console-producer.sh --broker-list localhost:9092 --topic <name of your topic>
Consume messages from a topic.
# 消费来自某个topic的消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <name of your topic> --from-beginning
Or
# or
kafka-simple-consumer-shell.sh --broker-list <hostname:port, ..., hostname:port> --topic <name of your topic>
# 删除topic
kafka-topics.sh --zookeeper localhost:2181 --delete --topic <name of your topic>