简体   繁体   English

如何使Kafka消费者订阅新分区

[英]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.

相关问题 如果消费者比分区更多,kafka消费者如何工作 - How kafka consumer works if consumers are more that partitions 我应该为kafka消费者创建多少个分区? - How many partitions should I create for kafka consumers? 如何为具有多个分区的 Kafka 主题启动多个使用者? - How can I start multiple consumers for a Kafka topic with multiple partitions? 如何在分区数量恒定和消费者数量动态的情况下提高 Kafka 的吞吐量 - How to increase throughput in Kafka with a constant number of partitions and dynamic number of consumers kafka 消费者/生产者如何提交消息/分区? - How does kafka consumers/producers commit messages/partitions? 当新消费者连接时,Kafka消费者会获得许多重播 - Kafka Consumers get many replays when new consumers connect Kafka 重新平衡 - 将 Kafka 消费者分配给分区 - Kafka rebalancing - assignement of Kafka consumers to partitions kafka中分区比consumer少,如何优化那个consumer group的其他consumer - Less partitions than consumers in kafka, how to Optimize other consumers of that consumer group 如何在Kafka中动态添加新的应用程序使用者 - How to add new Application consumers on the fly in Kafka Kafka:监控分配给分区主题的消费者的延迟 - Kafka: Monitor the lag for the consumers that are assigned to partitions topic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM