kafka-reassign-partitions
An overview of the kafka-reassign-partitions
tool.
This tool provides substantial control over partitions in a Kafka cluster. It is mainly used to balance storage loads across brokers through the following reassignment actions:
- Change the ordering of the partition assignment list. Used to control leader imbalances between brokers.
- Reassign partitions from one broker to another. Used to expand existing clusters.
- Reassign partitions between log directories on the same broker. Used to resolve storage load imbalance among available disks in the broker.
- Reassign partitions between log directories across multiple brokers. Used to resolve storage load imbalance across multiple brokers.
The tool uses two JSON files for input. Both of these are created by the user. The two
files are the following:
- Topics-to-Move JSON
- Reassignment Configuration JSON
- Topics-to-Move JSON
- This JSON file specifies the topics that you want to reassign. This a simple file that
tells the
kafka-reassign-partitions
tool which partitions it should look at when generating a proposal for the reassignment configuration. The user has to create the topics-to-move JSON file from scratch.The format of the file is the following:{"topics": [{"topic": "mytopic1"}, {"topic": "mytopic2"}], "version":1 }
- Reassignment Configuration JSON
- This JSON file is a configuration file that contains the parameters used in the
reassignment process. This file is created by the user, however, a proposal for its
contents is generated by the tool. When the
kafka-reasssign-partitions
tool is executed with the--generate
option, it generates a proposed configuration which can be fine-tuned and saved as a JSON file. The file created this way is the reassignment configuration JSON. To generate a proposal, the tool requires a topics-to-move file as input.The format of the file is the following:{"version":1, "partitions": [{"topic":"mytopic1","partition":3,"replicas":[4,5],"log_dirs":["any","any"]}, {"topic":"mytopic1","partition":1,"replicas":[5,4],"log_dirs":["any","any"]}, {"topic":"mytopic2","partition":2,"replicas":[6,5],"log_dirs":["any","any"]}] }
The reassignment configuration contains multiple properties that each control and specify an aspect of the configuration. The Reassignment Configuration Properties table lists each property and its description.
Property | Description |
---|---|
topic |
Specifies the topic. |
partition |
Specifies the partition. |
replicas |
Specifies the brokers that the selected partition is assigned to. The brokers are listed in order, which means that the first broker in the list is always the leader for that partition. Change the order of brokers to resolve any leader balancing issues among brokers. Change the broker IDs to reassign partitions to different brokers. |
log_dirs |
Specifies the log directory of the brokers. The log directories are listed in the
same order as the brokers. By default any is specified as the log
directory, which means that the broker is free to choose where it places the replica.
By default, the current broker implementation selects the log directory using a
round-robin algorithm. An absolute path beginning with a / can be
used to explicitly set where to store the partition replica. |
Notes and Recommendations:
- Cloudera recommends that you minimize the volume of replica changes per command instance. Instead of moving 10 replicas with a single command, move two at a time in order to save cluster resources.
- This tool cannot be used to make an out-of-sync replica into the leader partition.
- Use this tool only when all brokers and topics are healthy.
- Anticipate system growth. Redistribute the load when the system is at 70% capacity. Waiting until redistribution becomes necessary due to reaching resource limits can make the redistribution process extremely time consuming.