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}
我在 Java 7 中使用 Kafka 9.0.0 版.
I'm using Kafka version 9.0.0 with Java 7.
推荐答案
So you are try to access offset(29898318
) in topic(test
) partition()>0
) 目前不可用.
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
配置设置为earliest
或latest
.您可以在此处 找到有关此的更多信息 - 您可以通过以下方式获得可用于主题分区的
smallest offset
运行以下 Kafka 命令行工具
- Set
auto.offset.reset
config to eitherearliest
orlatest
. 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屋!
查看全文