kafka调整offset

实时平台操作kafka偏移至最早位置操作步骤:
1、终止任务,并清理状态如果任务开启了状态后端的话;

2、执行kafka命令,查看所有的group消费分组

bin/kafka-consumer-groups.sh --bootstrap-server 10.0.32.38:6667,10.0.32.39:6668,10.0.32.40:6669 --list


3、选择你的任务的groupid

一般以{Topic名称}_consumer_group_{任务Id} 名称,例如:action_report_topic_consumer_group_225

4、查看具体分组分区消费信息:

bin/kafka-consumer-groups.sh --bootstrap-server 10.0.32.38:6667,10.0.32.39:6668,10.0.32.40:6669 --group action_report_topic_consumer_group_225 --describe

 

5、移动偏移至最早

/usr/hdp/3.1.0.0-78/kafka/bin/kafka-consumer-groups.sh --bootstrap-server 10.0.32.38:6667,10.0.32.39:6668,10.0.32.40:6669 --group action_report_topic_consumer_group_225 --reset-offsets --topic TOPIC名字 --to-earliest --execute

 

6、移动偏移至最新

bin/kafka-consumer-groups.sh --bootstrap-server xxx.xxx.xxx.xxx:9092 --group action_report_topic_consumer_group_225 --reset-offsets --topic TOPIC名字 -to-latest --execute

 

7、移动相对偏移至
向早期移动100偏移:

bin/kafka-consumer-groups.sh --bootstrap-server --bootstrap-server xxx.xxx.xxx.xxx:9092 --group action_report_topic_consumer_group_225 --topic TOPIC名字 --shift-by -100 --reset-offsets --execute


向后期移动100偏移:

bin/kafka-consumer-groups.sh --bootstrap-server --bootstrap-server xxx.xxx.xxx.xxx:9092 --group action_report_topic_consumer_group_225 --topic TOPIC名字 --shift-by 100 --reset-offsets --execute


8、移动到指定时间偏移

bin/kafka-consumer-groups.sh --bootstrap-server --bootstrap-server xxx.xxx.xxx.xxx:9092 --group action_report_topic_consumer_group_225 --topic TOPIC名字 --to-datetime 2020-11-07T00:00:00.000 --reset-offsets --execute

 

posted @ 2020-11-09 15:33  一米八大高个儿  阅读(1538)  评论(0编辑  收藏  举报