查看topic信息:
bin/kafka-topics.sh --list --bootstrap-server common1:9092
查看topic内容:
bin/kafka-console-consumer.sh --bootstrap-server common1:9092 --topic hbcs_db --from-beginning
创建topic:
bin/kafka-topics.sh --create --bootstrap-server common1:9092 --topic ctest --partitions 2 --replication-factor 2
生产:
bin/kafka-console-producer.sh --broker-list common1:9092 --topic ctest
消费:
bin/kafka-console-consumer.sh --bootstrap-server common1:9092 --topic ctest --from-beginning
查看偏移量(offset最大值):
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list common1:9092 -topic ctest --time -1
查询结果:ctest:0:1
ctest:1:1
第一列代表topic,第二列代表partition,第三列代表offset