How to set Kafka offsets of a consumer group to a predefined list for all partitions at once?
I often face the situation when something happens with topic processing or I simply created duplicate of the topic, and I need to restore all the offsets for some consumer group.
You can use the docker image called 'wurstmeister/kafka' pulled from DockerHub to not install and build Kafka on my environment.
docker run -v ~:/mydata wurstmeister/kafka /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server --bootstrap-server b-1.localhost:9092,b-2.localhost:9092 --group js_companies_reimport_group_prod --topic topic_name --reset-offsets --from-file /mydata/temp.csv --execute
Your CSV file should have the next structure where the first column is the name of your topic, the second is the index of your partition and the third is the offset you want to set for it:
topic_name,1,93757
topic_name,2,99793
topic_name,3,93382
topic_name,4,93767
topic_name,5,102769
topic_name,6,93335
PreviousHow to view all of the offsets for some consumer groups in Kafka using CLI?NextTransform the number from one numeric range to another
Last updated