问题描述
我有一个有两个主题的小组.我正在尝试将其中一个的偏移量重置为 1
,但收到一条消息,指出偏移量 (1) 低于主题分区的最早偏移量.
I have a group with two topics. I am trying to reset the offset of one of them to 1
but getting a message that offset (1) is lower than earliest offset for topic partition.
➜ local-kafka_2.12-2.0.0 bin/kafka-consumer-groups.sh --bootstrap-server myserver:1025 --group mygroup --topic mytopic --reset-offsets --to-offset 1 --dry-run
[2019-01-31 21:41:35,664] WARN New offset (1) is lower than earliest offset for topic partition mytopic-0. Value will be set to 121 (kafka.admin.ConsumerGroupCommand$)
TOPIC PARTITION NEW-OFFSET
mytopic 0 121
当我尝试不同的分区时收到相同的消息:
I get the same message when I try different partitions:
➜ local-kafka_2.12-2.0.0 bin/kafka-consumer-groups.sh --bootstrap-server myserver:1025 --group mygroup --topic mytopic:0,1,2 --reset-offsets --to-offset 1 --dry-run
[2019-01-31 21:43:16,526] WARN New offset (1) is lower than earliest offset for topic partition mytopic-0. Value will be set to 121 (kafka.admin.ConsumerGroupCommand$)
[2019-01-31 21:43:16,528] WARN New offset (1) is higher than latest offset for topic partition mytopic-1. Value will be set to 0 (kafka.admin.ConsumerGroupCommand$)
[2019-01-31 21:43:16,528] WARN New offset (1) is higher than latest offset for topic partition mytopic-2. Value will be set to 0 (kafka.admin.ConsumerGroupCommand$)
TOPIC PARTITION NEW-OFFSET
mytopic 0 121
mytopic 1 0
mytopic 2 0
有没有办法将偏移量设置为 1?或者更好的是,为什么我无法将 kafka 主题重置为 1?
Is there a way I can set the offset to 1? or better yet why am I not able to reset the kafka topic to 1?
推荐答案
这意味着mytopic-2
的结束偏移为零,主要是因为这个分区中没有存储记录,所以你不能设置更大的-比零偏移.
This means the end offset for mytopic-2
is zero, largely due to the fact there is no record stored in this partition, so you cannot set a greater-than-zero offset.
新偏移量 (1) 低于主题分区 mytopic-0 的最早偏移量.值将设置为 121
这意味着mytopic-0
的起始偏移量是121,这是允许暴露给客户端的最早偏移量,所以你不能为这个分区.可能会更新起始偏移量的情况包括: 1. 日志保留;2.日志截断;3. 发出kafka-delete-records脚本或DeleteRecordsRequest.
This means the start offset for mytopic-0
is 121, which is the earliest offset allowed to be exposed to the client, so you cannot set a lower offset for this partition. Possible situations where start offset will be updated includes: 1. log retention; 2.log truncation; 3. issuing kafka-delete-records script or DeleteRecordsRequest.
这篇关于无法将组中的 kafka 主题重置为 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!