首页 > 技术文章 > kafka查看topic和消息内容命令

deepJL 2021-07-19 16:56 原文

1、查询topic,进入kafka目录:
bin/kafka-topics.sh --list --zookeeper localhost:2181

2、查询topic内容:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topicName --from-beginning

查询topic
./bin/kafka-topics.sh --bootstrap-server hadoop102:9092
创建topic
./bin/kafka-topics.sh --bootstrap-server hadoop102:9092 --create --topic first --partitions 4 --replication-factor 2
查看topic 为 first的 详细信息
./bin/kafka-topics.sh --bootstrap-server hadoop102:9092 --describe --topic first
往topic 为 first 的内部生产消息
./bin/kafka-console-producer.sh --broker-list hadoop102:9092 --topic first
从topic 为first的内部消费消息
./bin/kafka-console-consumer.sh --bootstrap-server hadoop102:9092 --topic first

推荐阅读