kafka常用命令
启动kafka
bin/kafka-server-start.sh -daemon config/server.properties
#或者
nohup bin/kafka-server-start.sh -daemon config/server.properties &
查看当前服务器中的所有topic
bin/kafka-topics.sh --zookeeper localhost:2181 --list
创建topic
bin/kafka-topics.sh --zookeeper localhost:2181 --create --replication-factor 1 --partitions 1 --topic first
#--replication-factor 设置副本数量
#--partitions设置分区个数
删除topic
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic first
#配置文件中delete.topic.enable=true才可删除(官方默认是true)
开启控制台生产者,向指定topic写数据
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic first
开启控制台消费者,消费指定topic中的数据
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first --from-beginning
#注: --from-beginning:会把first主题中以往所有的数据都读取出来。根据业务场景选择是否增加该配置。
查看某个topic详情
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic first
查看某个group 消费详情
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group test-group
持续更新中。。。。。。