第一步:本地启动两个节点,分别配置监听为broker0=ip:9092和broker=ip:9094,并且启动重平衡频率为5s,10%;创建一个topic有5个分区2个备份
kafka_2.13-3.4.0$ bin/kafka-topics.sh --describe --topic test2 --bootstrap-server ip:9092
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节点下线,此时启用broker0的备份,查询topic详情发现所有分区的leader都是broker0,原本leader是broker1的分区的备份的优先副本还是1
kafka_2.13-3.4.0$ bin/kafka-topics.sh --describe --topic test2 --bootstrap-server ip:9092
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
第三步:再启动broker1,不知道为什么始终没有重平衡分区,查询的topic详情和第二步的一样,反过来下线broker0再上线的话就触发重平衡,查询到的分区详情就和第一步一样,
为什么broker1下线再上线没有触发重平衡,而broker0下线再上线就触发了重平衡?
参考:kafka平衡leader
你的答案