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

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

可能有两种情况

  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 配置设置为 earliestlatest .您可以在此处
  2. 找到有关此的更多信息
  3. 您可以通过以下方式获得可用于主题分区的smallest offset运行以下 Kafka 命令行工具
  1. Set auto.offset.reset config to either earliest or latest . 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天全站免登陆