Reassignment Kafka topics on new nodes
Revision | Date | Description |
|---|---|---|
| 24.07.2024 | Init Changelog |
Run task
Reassignment task can be started with kafka-reassign-partitions.sh script places in Kafka dir.
./kafka-reassign-partitions.sh --bootstrap-server BROKER_LIST --topics-to-move-json-file input.json --broker-list "1,2,3...." --generate --command-config client.properties > output.json
Where:
--broker-list- pass list of brokers hostname with ports (like:host1:port,host2:port).--topics-to-move-json-file- JSON file with list of topics to reassign, like:{ "topics": [ { "topic": "Topic-1" }, { "topic": "Topic-2" } ], "version": 1 }
Script output should look like below:
Current partition replica assignment
{"version":1,"partitions":[{"topic":"topic-1","partition":0,"replicas":[3,1,2]...
Proposed partition reassignment configuration
{"version":1,"partitions":[{"topic":"topic-1","partition":0,"replicas":[3,2,4],...
Take last line (JSON code), which is partition reassignment propose. That code set as input file for execute command:
./kafka-reassign-partitions.sh --bootstrap-server BROKER_LIST --command-config client.properties --reassignment-json-file propose.json --execute > output
Above command output should contain current partition assignment config, in case of rollback.
Get topic list
Run command below:
./kafka-topics.sh --bootstrap-server BROKER_LIST --command-config client.properties --list > topic.list
Convert list into JSON: https://wtools.io/convert-list-to-json-array
In IDE (like VSCode) change all:
,
to
}, {"topic":
Fix JSON close.
Last modified: 17 February 2025