topic partition leader rebalance

Before leader rebalance, there are several partitions leader in on broker1

[root@es1 ~]# kafka-topics.sh --describe --zookeeper localhost:2181 --topic resshows_test
Topic:resshows_test  PartitionCount:6    ReplicationFactor:2 Configs:retention.ms=345600000,cleanup.policy=delete
    Topic: resshows_test Partition: 0    Leader: 1   Replicas: 1,2   Isr: 1,2
    Topic: resshows_test Partition: 1    Leader: 2   Replicas: 2,3   Isr: 2,3
    Topic: resshows_test Partition: 2    Leader: 1   Replicas: 3,1   Isr: 1,3
    Topic: resshows_test Partition: 3    Leader: 1   Replicas: 1,3   Isr: 1,3
    Topic: resshows_test Partition: 4    Leader: 1   Replicas: 2,1   Isr: 1,2
    Topic: resshows_test Partition: 5    Leader: 3   Replicas: 3,2   Isr: 2,3

Write rebalance file
vi resshows_test.json

{"partitions":[{"topic":"resshows_test","partition": 0},{"topic":"resshows_test","partition": 1},{"topic":"resshows_test","partition": 2},{"topic":"resshows_test","partition": 3},{"topic":"resshows_test","partition": 4},{"topic":"resshows_test","partition": 5}]}

Rebalancing leader

kafka-preferred-replica-election.sh --zookeeper localhost:2181 --path-to-json-file resshows_test.json

After equalizing

[root@es1 ~]# kafka-topics.sh --describe --zookeeper localhost:2181 --topic resshows_test
Topic:resshows_test  PartitionCount:6    ReplicationFactor:2 Configs:retention.ms=345600000,cleanup.policy=delete
    Topic: resshows_test Partition: 0    Leader: 1   Replicas: 1,2   Isr: 1,2
    Topic: resshows_test Partition: 1    Leader: 2   Replicas: 2,3   Isr: 2,3
    Topic: resshows_test Partition: 2    Leader: 3   Replicas: 3,1   Isr: 1,3
    Topic: resshows_test Partition: 3    Leader: 1   Replicas: 1,3   Isr: 1,3
    Topic: resshows_test Partition: 4    Leader: 2   Replicas: 2,1   Isr: 1,2
    Topic: resshows_test Partition: 5    Leader: 3   Replicas: 3,2   Isr: 2,3
Published 118 original articles · won praise 37 · views 170 000 +

Guess you like

Origin blog.csdn.net/woloqun/article/details/104018353