[英]How to get Kafka consumers to subscribe to new Partitions
I have a couple of Kafka consumers subscribed to a topic and need to add some partitions. 我有几个Kafka使用者订阅了一个主题,需要添加一些分区。 I'm playing around in the staging environment and add some new partitions.
我正在暂存环境中玩耍并添加一些新分区。 My understanding of Kafka is that they should automatically rebalance and they subscribe to the new partitions.
我对Kafka的理解是,它们应该自动重新平衡并订阅新分区。 Except they don't, restarting doesn't help.
除非他们不这样做,重新启动没有帮助。 Each time I've done this (twice now) magically overnight the consumers subscribe to the new partitions.
每次我完成此操作(现在两次)后,消费者都会神奇地在一夜之间订阅新分区。
If I create a new test group in a console it subscribes to the new partitions fine. 如果我在控制台中创建一个新的测试组,则它可以很好地订阅新分区。 But subscribing with the existing group id in the console, rebalances the workers but doesn't include the new partitions.
但是在控制台中订阅现有的组ID,可以重新平衡工作程序,但不包括新的分区。
Why are they not subscribing when the partitions are created? 为什么在创建分区时不订阅? And what is happening overnight that is causing them to start seeing the new partitions?
一夜之间发生了什么,使他们开始看到新的分区?
By default, clients (consumers and producers) refresh their metadata every 5 minutes. 默认情况下,客户端(消费者和生产者)每5分钟刷新一次元数据。 This is determine by
metadata.max.age.ms
. 这由
metadata.max.age.ms
确定。
In your example, consumers will find new partitions only when refreshing their metadata. 在您的示例中,使用者只有在刷新其元数据时才能找到新分区。 So you either need to set this setting to a lower value or wait a bit.
因此,您需要将此设置设置为较低的值,或者稍等片刻。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.