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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM