Kafka:重置主题特定分区的偏移量 [英] Kafka : Reset offset of a specific partition of topic

查看:48
本文介绍了Kafka:重置主题特定分区的偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重置 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.

适用于所有分区的命令

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.

推荐答案

要仅更改特定分区的偏移量,您必须通过 --topic 标志、主题名称和分区编号想修改.

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.

可以使用以下命令:

./bin/kafka-consumer-groups.sh --bootstrap-server localhost:1111 --group grId --topic someTopicName:0 --reset-offsets --shift-by 1 --execute

来自 kafka-consumer.groups.sh 的总结可能会帮助你更好地理解它:

A summary from kafka-consumer.groups.sh may help you understand it better:

--topic :消费者组的主题信息应被删除或应包含在其中的主题复位偏移过程.在 reset-offsets 情况下,分区可以是使用以下格式指定:topic1:0,1,2,其中 0,1,2 是要包含在进程中的分区.重置偏移也支持多个主题输入.

--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.

这篇关于Kafka:重置主题特定分区的偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆