kafka常用操作命令

创建topic

replication-factor 表示该topic需要在不同的broker中保存几份, partitions为几个分区

/opt/cloudera/parcels/KAFKA/bin/kafka-topics --zookeeper "master01:2181,master02:2181,slave01:2181" --create --replication-factor 1 --partitions 10 --topic N603_A_1_glen

查看所有topic

kafka-topics --list --zookeeper slave01:2181

删除topic

kafka-topics --zookeeper 127.0.0.1:2181 --delete --topic test

生产消费测试

生产

kafka-console-producer --broker-list master02:9092 --topic test

消费

--from-b 参数会加载之前的消息

kafka-console-consumer --zookeeper master02:2181 --topic test --from-b

原文地址:https://www.cnblogs.com/starcor/p/9542191.html