本地启动两个节点,分别配置监听为broker0=ip:9092和broker=ip:9094,并且启动重平衡频率为5s,10%;创建一个topic有5个分区2个备份,平均分配到了节点上,然后将broker1节点下线,此时启用broker0的备份,查询topic详情发现所有分区的leader都是broker0,备份的优先副本还是1,此时再启动broker1,始终没有重平衡分区,查询的topic详情是下面第二种情况,反过来下线broker0再上线的话就触发重平衡,这是为什么?
启动两个broker后创建topic查看topic详情时是:
Topic: test2 TopicId: y2dwPl1ZTeqoFYCJiDS_2A PartitionCount: 5 ReplicationFactor: 2 Configs: retention.ms=20,retention.bytes=20
Topic: test2 Partition: 0 Leader: 1 Replicas: 1,0 Isr: 1,0
Topic: test2 Partition: 1 Leader: 0 Replicas: 0,1 Isr: 1,0
Topic: test2 Partition: 2 Leader: 1 Replicas: 1,0 Isr: 1,0
Topic: test2 Partition: 3 Leader: 0 Replicas: 0,1 Isr: 1,0
Topic: test2 Partition: 4 Leader: 1 Replicas: 1,0 Isr: 1,0
然后下线broker1之后,topic详情一直是这样的:
Topic: test2 TopicId: y2dwPl1ZTeqoFYCJiDS_2A PartitionCount: 5 ReplicationFactor: 2 Configs:
Topic: test2 Partition: 0 Leader: 0 Replicas: 1,0 Isr: 0
Topic: test2 Partition: 1 Leader: 0 Replicas: 0,1 Isr: 0
Topic: test2 Partition: 2 Leader: 0 Replicas: 1,0 Isr: 0
Topic: test2 Partition: 3 Leader: 0 Replicas: 0,1 Isr: 0
Topic: test2 Partition: 4 Leader: 0 Replicas: 1,0 Isr: 0
参考:kafka平衡leader
你的答案