Kafka集群消息发送和消费的相关命令

#发送消息

./bin/kafka-console-producer.sh --broker-list 192.168.20.113:9092,192.168.20.114:9092,192.168.20.115:9092 --topic  test

#从开始消费消息

./bin/kafka-console-consumer.sh --zookeeper 192.168.20.113:2181,192.168.20.114:2181,192.168.20.115:2181 --topic test    --from-beginning

#实时消费发送到topic的消息

./bin/kafka-console-consumer.sh --zookeeper 192.168.20.113:2181,192.168.20.114:2181,192.168.20.115:2181 --topic  test

# 高级点的用法 指定offset 消费

 ./bin/kafka-simple-consumer-shell.sh --brist localhost:9092 --topic test --partition 0 --offset 1234  --max-messages 10

列出全部topic的信息 –describe

 ./bin/kafka-topics.sh --describe --zookeeper 192.168.20.113:2181,192.168.20.114:2181,192.168.20.115:2181 --topic  test

# 消费者列表查询

  ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list

# 新消费者列表查询(支持0.9版本+)

 ./bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --list

#列出了所有消费者组的所有信息

 ./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper 192.168.20.113:2181,192.168.20.114:2181,192.168.20.115:2181   --group=WordcountConsumerGroup  --topic  test

#查看custom-list组内消费的 offset :

 ./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper 192.168.20.113:2181,192.168.20.114:2181,192.168.20.115:218   --group  custom-list  --topic  test

转载注明原文:Kafka集群消息发送和消费的相关命令