Kafka使用者偏移超出范围,没有为分区配置任何重置策略 [英] Kafka consumer offsets out of range with no configured reset policy for partitions

查看:117
本文介绍了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.

可能有两种情况

  1. 您的主题分区0可能没有那么多消息
  2. 您的偏移量为29898318的邮件可能已在保留期之前删除
  1. Your topic partition 0 may not have those many messages
  2. Your message at offset 29898318 might have already deleted by retention period

为避免这种情况,您可以执行以下操作之一:

To avoid this you can do one of following:

  1. auto.offset.reset配置设置为smallestlargest. 您可以在此处
  2. 中找到更多信息.
  3. 您可以通过以下方式获取用于主题分区的smallest offset 在Kafka命令行工具下运行
  1. Set auto.offset.reset config to either smallest or largest . You can find more info regarding this here
  2. 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屋!

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