Reassignment examples
A collection of examples that demonstrate how users can modify the proposed
configuration file generated by the kafka-reassign-partitions
.
There are multiple ways to modify the configuration file. The following list of examples shows how a user can modify a proposed configuration and what these changes do.
Suppose that the
kafka-reassign-partitions
tool generated the following
proposed reassignment
configuration:{"version":1,
"partitions":
[{"topic":"mytopic1","partition":0,"replicas":[1,2],"log_dirs":["any","any"]}]}
Now
let's look at how this reassignment configuration has to be changed in different reassignment
scenarios. - Reassign partitions between brokers
-
To reassign partitions from one broker to another, change the broker ID specified in
replicas
. For example:{"topic":"mytopic1","partition":0,"replicas":[5,2],"log_dirs":["any","any"]}
This reassignment configuration moves partition mytopic1-0 from broker 1 to broker 5.
- Reassign partitions to another log directory on the same broker
- To reassign partitions between log directories on the same broker, change the
appropriate
any
entry to an absolute path. For example:{"topic":"mytopic1","partition":0,"replicas":[1,2],"log_dirs":["/log/directory1","any"]}
This reassignment configuration moves partition mytopic1-0 to the /log/directory1 log directory.
- Reassign partitions between log directories across multiple brokers
- To reassign partitions between log directories across multiple brokers, change the
broker ID specified in
replicas
and the appropriateany
entry to an absolute path. For example:{"topic":"mytopic1","partition":0,"replicas":[5,2],"log_dirs":["/log/directory1","any"]}
This reassignment configuration moves partition mytopic1-0 to /log/directory1 on broker 5.
- Change partition assignment order (elect a new leader)
-
To change the ordering of the partition assignment list, change the order of the brokers in
replicas
. For example:{"topic":"mytopic1","partition":0,"replicas":[2,1],"log_dirs":["any","any"]}
This reassignment configuration elects broker 2 as the new leader.