[ https://issues.apache.org/jira/browse/KAFKA-5319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16022687#comment-16022687 ]
ASF GitHub Bot commented on KAFKA-5319: --------------------------------------- GitHub user MarkTcMA opened a pull request: https://github.com/apache/kafka/pull/3136 KAFKA-5319 Add a tool to make cluster replica and leader balance As [KAFKA-5319](https://issues.apache.org/jira/browse/KAFKA-5319) describes Kafka does not have tools to make replica or leader num of cluster balanced ,I write a tool to deal with it. You can merge this pull request into a Git repository by running: $ git pull https://github.com/MarkTcMA/kafka trunk Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/3136.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3136 ---- commit de71981cf6ca42f39ed1fc44ef34f698afcf6e60 Author: 马天池 <m...@neunn.com> Date: 2017-05-24T02:49:32Z add a new command which make replica and leader on broker balanced commit 19a455e4eb38d6f992466901c0466e2aa8aaa36f Author: 马天池 <m...@neunn.com> Date: 2017-05-24T06:31:32Z no message commit fec1f099bce34158a18062e9f6d6245863c6d2e5 Author: 马天池 <m...@neunn.com> Date: 2017-05-24T07:55:26Z no message commit 6af378a777c450193c279a3b8b995bfccea2a55f Author: Ma Tianchi <mail_to_matian...@163.com> Date: 2017-05-24T08:03:16Z a command to make replica and leader balanced commit 6050af726f30ffbb3e7281e135bbdb2a57e94c80 Author: Ma Tianchi <mail_to_matian...@163.com> Date: 2017-05-24T10:04:18Z Add a tool to make cluster replica and leader balance ---- > Add a tool to make cluster replica and leader balance > ----------------------------------------------------- > > Key: KAFKA-5319 > URL: https://issues.apache.org/jira/browse/KAFKA-5319 > Project: Kafka > Issue Type: Improvement > Components: admin > Affects Versions: 0.10.2.1 > Reporter: Ma Tianchi > Attachments: ClusterBalanceCommand.scala > > > When a new broker is added to cluster,there is not any topics in the new > broker.When we use console command to create a topic without > 'replicaAssignmentOpt',Kafka use AdminUtils.assignReplicasToBrokers to get > replicaAssignment.Even though it is balance at the creating time if the > cluster never change,with more and more brokers added to cluster the replica > balanced will become not well. We also can use 'kafka-reassign-partitions.sh' > to balance ,but the big amount of topics make it not easy.And at the topic > created time , Kafka choose a PreferredReplicaLeader which be put at the > first position of the AR to make leader balance.But the balance will be > destroyed when cluster changed.Using 'kafka-reassign-partitions.sh' to make > partition reassignment may be also destroy the leader balance ,because user > can change the AR of the partition . It may be not balanced , but Kafka > believe cluster leader balance is well with every leaders is the first on at > AR. > So we create a tool to make the number of replicas and number of leaders on > every brokers is balanced.It uses a algorithm to get a balanced replica and > leader reassignment,then uses ReassignPartitionsCommand to real balance the > cluster. > It can be used to make balance when cluster added brokers or cluster is not > balanced .It does not deal with moving replicas of a dead broker to an alive > broker,it only makes replicas and leaders on alive brokers is balanced. -- This message was sent by Atlassian JIRA (v6.3.15#6346)