topic partition leader rebalance

leader rebalance之前,有好几个分区的leader都在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

编写rebalance文件
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}]}

leader重新均衡

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

均衡之后

[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值