创建topic:
bin/kafka-topics.sh --create --zookeeper zk1:2181,zk2:2181 --replication-factor 2 --partitions 1 --topic test
replication:数据保存副本数量,分布式文件容错
partitions:kafka主题的分区数量,对应消费者的消费并发读取数据数量
查看topic:
bin/kafka-topics.sh --list --zookeeper localhost:2181
查看topic详细描述:
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
删除topic:
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test
Attention!!!:如果kafaka启动的时候,配置文件中server.properties没有配置delete.topic.enable=true选项,
此时的删除并不是真正的删除,而是把topic标记为:marked for deletion,只是标记为删除,
真正删除它,登录zookeeper客户端,进入终端后,删除相应节点就OK
shell模拟生产消息:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
shell模拟消费消息:
bin/kafka-console-consumer.sh --zookeeper master:2181 --topic test --from-
beginning