新的kafka节点能够使用现有主题吗?

问题描述

假设我们有一个三节点kafka集群,并且在创建主题时只有两个节点处于活动状态。然后,如果我们将第三个节点放回原处,它将能够赶上这个新创建的主题的所有数据。在第三个节点出现后,当我描述第三个节点没有充当分区的负责人时,我尝试关闭其他两个节点。

Topic: test PartitionCount: 6   ReplicationFactor: 2    Configs: segment.bytes=1073741824
Topic: test Partition: 0    Leader: none    Replicas: 0,1   Isr: 0
Topic: test Partition: 1    Leader: none    Replicas: 1,0   Isr: 0
Topic: test Partition: 2    Leader: none    Replicas: 0,1   Isr: 0
Topic: test Partition: 3    Leader: none    Replicas: 1,0   Isr: 0
Topic: test Partition: 4    Leader: none    Replicas: 0,1   Isr: 0
Topic: test Partition: 5    Leader: none    Replicas: 1,0   Isr: 0

它没有显示吗?

解决方法

您创建的主题有ReplicationFactor: 2。这意味着只有2个经纪人拥有此主题的数据。

由于您有2个代理(0和1)正在运行,因此将它们选为副本。您可以看到所有分区的所有副本位于0和1上。没有其他代理包含有关此主题的数据。

启动第三个经纪人时,它将不会托管此主题的副本。因此,它将无法成为领导者。

如果您希望第三个代理也成为副本,则可以将复制因子扩展为3,例如在https://kafka.apache.org/documentation/#basic_ops_increase_replication_factor之后

请注意,如果仅运行2个代理,则将无法创建复制因子设置为3的主题。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...