Kafka使用者偏移超出范围,没有为分区配置任何重置策略 [英] Kafka consumer offsets out of range with no configured reset policy for partitions
本文介绍了Kafka使用者偏移超出范围,没有为分区配置任何重置策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
启动Kafka使用者时收到异常消息.
I'm receiving exception when start Kafka consumer.
org.apache.kafka.clients.consumer.OffsetOutOfRangeException: 没有为分区配置重设策略的偏移量超出范围{test-0 = 29898318}
org.apache.kafka.clients.consumer.OffsetOutOfRangeException: Offsets out of range with no configured reset policy for partitions{test-0=29898318}
我正在将Kafka版本9.0.0与Java 7结合使用.
I'm using Kafka version 9.0.0 with Java 7.
推荐答案
因此,您正在尝试访问主题(test
)分区(0
)中的偏移量(29898318
),该功能目前不可用.
So you are trying to access offset(29898318
) in topic(test
) partition(0
) which is not available right now.
可能有两种情况
- 您的主题分区
0
可能没有那么多消息 - 您的偏移量为
29898318
的邮件可能已在保留期之前删除
- Your topic partition
0
may not have those many messages - Your message at offset
29898318
might have already deleted by retention period
为避免这种情况,您可以执行以下操作之一:
To avoid this you can do one of following:
- 将
auto.offset.reset
配置设置为smallest
或largest
. 您可以在此处 中找到更多信息.
- 您可以通过以下方式获取用于主题分区的
smallest offset
在Kafka命令行工具下运行
- Set
auto.offset.reset
config to eithersmallest
orlargest
. You can find more info regarding this here - You can get
smallest offset
available for a topic partition by running following Kafka command line tool
命令:
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list <broker-ip:9092> --topic <topic-name> --time -2
希望这会有所帮助!
这篇关于Kafka使用者偏移超出范围,没有为分区配置任何重置策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文