I am trying to reset offset of a specific partition of a kafka topic but i did not find any command.
I was able to reset offset of all the partition of a topic using the below command but i want to reset offset only for a specific partitions.
Command which worked for all partitions
kafka-consumer-groups.sh -- bootstap-server localhost:1111 -- command-config <file> -- group <group> -- topic <topic> -- reset-offset -- shift-by -1
The above command doesnt accept partition, and resets for all partitions. How can i reset only specific partition.
To change offset only for a particular partition, you have to pass with --topic
flag, topic name and partition number that you would like to modify.
Following command can be used:
./bin/kafka-consumer-groups.sh --bootstrap-server localhost:1111 --group grId --topic someTopicName:0 --reset-offsets --shift-by 1 --execute
A summary from kafka-consumer.groups.sh
may help you understand it better:
--topic : The topic whose consumer group information should be deleted or topic whose should be included in the reset offset process. In
reset-offsets
case, partitions can be specified using this format:topic1:0,1,2
, where 0,1,2 are the partition to be included in the process. Reset-offsets also supports multiple topic inputs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With