Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka : Reset offset of a specific partition of topic

Tags:

apache-kafka

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.

like image 762
Abhishek Avatar asked Feb 26 '19 16:02

Abhishek


1 Answers

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.

like image 52
Bartosz Wardziński Avatar answered Sep 28 '22 08:09

Bartosz Wardziński