kafka命令大全
Posted yunger
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kafka命令大全相关的知识,希望对你有一定的参考价值。
创建主题:
创建主题(4个分区,2个副本)
kafka-topics.sh --create --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181 --replication-factor 2 --partitions 4 --topic test
查看集群详情:
kafka-topics.sh --describe --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181
查看集群中的topic列表:
kafka-topics.sh --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181 --list
查看topic详情:
kafka-topics.sh --describe --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181 --topic test
查看集群中的消费组列表:
kafka-consumer-groups.sh --bootstrap-server 192.168.130.37:9092,192.168.130.38:9092,192.168.130.39:9092 --list
查看消费组的消费情况:
kafka-consumer-groups.sh --bootstrap-server 192.168.130.37:9092,192.168.130.38:9092,192.168.130.39:9092 --describe --group consumer-group(消费组的名称)
生产者生产数据:
kafka-console-producer.sh --broker-list 192.168.130.37:9092,192.168.130.38:9092,192.168.130.39:9092 --topic test
消费者消费数据:
kafka-console-consumer.sh --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181 --topic test
kafka-console-consumer.sh --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181 --from-beginning --topic myz
新消费者
kafka-console-consumer.sh --bootstrap-server 192.168.130.37:9092,192.168.130.38:9092,192.168.130.39:9092 --topic test --new-consumer --from-beginning --consumer.config config/consumer.properties
kafka-simple-consumer-shell.sh --brist localhost:9092 --topic test --partition 0 --offset 1234 --max-messages 10
分区/扩容
kafka-topics.sh --zookeeper 192.168.130.37:2181,192.168.130.38:2181,192.168.130.39:2181 --alter --topic topic-name --partitions 2
以上是关于kafka命令大全的主要内容,如果未能解决你的问题,请参考以下文章