【问题标题】:NotEnoughReplicasException: The size of the current ISR Set(2) is insufficient to satisfy the min.isr requirement of 3NotEnoughReplicasException: 当前 ISR Set(2) 的大小不足以满足 min.isr 3 的要求
【发布时间】:2020-07-08 17:02:41
【问题描述】:

我有以下设置 代理:3 - 全部启动并运行 min.insync.replicas=3。

我使用以下配置创建了一个主题

bin\windows\kafka-topics --zookeeper 127.0.0.1:2181 --topic topic-ack-all --create --partitions 4 --replication-factor 3

我用“ack = all”触发了生产者并且生产者能够发送消息。 但是,当我启动消费者时,问题就开始了

bin\windows\kafka-console-consumer --bootstrap-server localhost:9094,localhost:9092 --topic topic-ack-all --from-beginning

错误是

NotEnoughReplicasException: 当前 ISR Set(2) 的大小为 不足以满足 3 的 min.isr 要求 NotEnoughReplicasException: 的大小 当前 ISR Set(3) 不足以满足 min.isr 要求 3 个分区 __con

我在这里看到两种错误。我浏览了文档,也了解了“min.isr”,但是,这些错误消息并不清楚。

  1. 当前 ISR 集是什么意思?每个主题是否有所不同?它的含义是什么?
  2. 我猜 min.isr 与 min.insync.replicas 相同。我希望它的价值至少与“复制因子”相同?

更新 #1

Topic: topic-ack-all    PartitionCount: 4       ReplicationFactor: 3    Configs:            
        Topic: topic-ack-all    Partition: 0    Leader: 1       Replicas: 1,2,3 Isr: 1,2,3  
        Topic: topic-ack-all    Partition: 1    Leader: 1       Replicas: 2,3,1 Isr: 1,2,3  
        Topic: topic-ack-all    Partition: 2    Leader: 1       Replicas: 3,1,2 Isr: 1,2,3  
        Topic: topic-ack-all    Partition: 3    Leader: 1       Replicas: 1,3,2 Isr: 1,2,3 

更新 2

Topic: __consumer_offsets       PartitionCount: 50      ReplicationFactor: 1    Configs: compression.type=producer,cleanup.policy=compact,segment.bytes=104857600
    Topic: __consumer_offsets       Partition: 0    Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 1    Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 2    Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 3    Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 4    Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 5    Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 6    Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 7    Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 8    Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 9    Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 10   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 11   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 12   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 13   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 14   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 15   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 16   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 17   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 18   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 19   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 20   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 21   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 22   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 23   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 24   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 25   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 26   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 27   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 28   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 29   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 30   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 31   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 32   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 33   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 34   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 35   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 36   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 37   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 38   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 39   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 40   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 41   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 42   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 43   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 44   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 45   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 46   Leader: 3       Replicas: 3     Isr: 3
    Topic: __consumer_offsets       Partition: 47   Leader: 1       Replicas: 1     Isr: 1
    Topic: __consumer_offsets       Partition: 48   Leader: 2       Replicas: 2     Isr: 2
    Topic: __consumer_offsets       Partition: 49   Leader: 3       Replicas: 3     Isr: 3

【问题讨论】:

  • 可以添加bin\windows\kafka-topics --zookeeper 127.0.0.1:2181 --describe的输出吗?
  • @MickaelMaison,刚刚添加。谢谢
  • 另外,“配置”标志有时显示某些状态而其他时候没有状态的原因是什么?
  • 运行消费时,__consumer_offsets 主题出现错误。您也可以添加该主题的描述吗?
  • @MickaelMaison 我刚刚添加,谢谢

标签: apache-kafka confluent-platform


【解决方案1】:

从您粘贴的输出来看,__consumer_offsets 主题似乎是使用单个副本创建的。

您的代理似乎也设置为min.insync.replicas = 3。

使用此配置,如果消费者提交偏移量,预计会获得NotEnoughReplicasException

__consumer_offsets 主题是在第一个消费者连接到集群时自动创建的。遇到这种情况的一种常见方法是,如果您运行了一个消费者,而您只运行了一个代理。在这种情况下,__consumer_offsets 将使用单个副本创建。

假设它是一个开发环境,恢复有效状态的最简单方法是删除 __consumer_offsets 并在所有 3 个代理都启动时重新运行您的消费者。

【讨论】:

  • 请让我承认假设是完全正确的。很少有后续问题。对于值为 3 的“min.insync.replicas”,我假设我们至少需要 3 个(或 4 个)经纪人?当前的 ISR 集是什么意思?每个主题都有不同的含义吗?你为什么认为它给出了这个抱怨——NotEnoughReplicasException:当前 ISR Set(3) 的大小不足以满足分区 __con 的 min.isr 要求 3。错误似乎发生了,因为 ISR 集应该大于 min.isr ,所以在这种情况下 - 需要 4 个代理?
  • 还有几个问题 - 所以,在创建集群之前应该就“min.insync.replicas”达成一致,以免出现这些混乱?如果没有,这可能需要根据生产中的主题进行更改?
  • 另外,“min.insync.replicas”可以和“复制因子”一样吗?
  • 问题太多了!您通常希望副本数(复制因子)大于 min.insync.replicas。这允许执行代理的滚动重启并保持一切正常。 3 个副本和 2 个 min.insync 是一种非常常见的配置,但是如果您需要 3 个 min.insync,那么您至少需要 4 个副本。所有这些设置都可以更改(即使在运行时),您始终可以将覆盖添加到主题。对于 prod 环境,您显然希望提前做出决定,但对于 dev 环境,您可以根据需要更改配置。
  • 我将“consumer_offsets”的配置更新为 1(因为这是原始值,现在可以正常工作) PS C:\confluent-5.5.0> bin\windows\kafka-configs - -zookeeper 127.0.0.1:2181 --entity-type 主题 --entity-name __consumer_offsets --add-config min.insync.replicas=1 --alter
猜你喜欢
  • 1970-01-01
  • 2011-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-27
  • 2019-05-11
  • 1970-01-01
  • 2016-12-06
相关资源
最近更新 更多