创建Topic
kafka-topics.sh --create --bootstrap-server localhost:9092 --topic abtest --partitions 2 --replication-factor 1
查看Topic都有哪些
kafka-topics.sh --list --zookeeper localhost:2181
生产者,将文件中的数据写入Kafka生产者
kafka-console-producer.sh --broker-list localhost:9092 --topic order_topic < abc.txt
消费者,从最开始的位移,消费Topic中的数据
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic order_topic --from-beginning
重置Consumer Group的Offset到最新位移
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group group_name_1 --reset-offsets --topic order_topic --to-latest --execute
查看消费者组Consumer Group位移
[homework@test ~]$ kafka-consumer-groups.sh --bootstrap-server host1:9092,host2:9092 --describe --group groupname_1
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
order 5 20781271 20781556 285 - - -
order 1 10553765 10554032 267 - - -
order 2 10634508 10634808 300 - - -
order 7 10375128 10375355 227 - - -
order 6 10435147 10435467 320 - - -
order 0 10640342 10640643 301 - - -
order 3 13762141 13762478 337 - - -
order 8 11176468 11176707 239 - - -
order 4 10443088 10443320 232 - - -
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/197822.html