Skip to content

Instantly share code, notes, and snippets.

@anosulchik
Last active October 9, 2023 18:41
Show Gist options
  • Save anosulchik/388effd73ecabf5148b7ab56f611059a to your computer and use it in GitHub Desktop.
Save anosulchik/388effd73ecabf5148b7ab56f611059a to your computer and use it in GitHub Desktop.
# https://catalog.workshops.aws/msk-labs/en-US/addingbrokers/reassignpartitions
$ cat <<EOF > topics-to-move.json
{ "topics": [ { "topic" : "my-topic"}, { "topic" : "__consumer_offsets"} ], "version":1}
EOF
$ cat <<EOF > client.properties
security.protocol=SSL
# ...
EOF
$ export KAFKA_BROKERS="..."
# Example of repalancing partitions amoung 6 brokers:
$ bin/kafka-reassign-partitions.sh --bootstrap-server "${KAFKA_BROKERS}" --command-config client.properties --topics-to-move-json-file topics-to-move.json --broker-list "1,2,3,4,5,6" --generate | awk -F: '/Proposed partition reassignment configuration/ { getline; print $0 }' | jq . > expand-cluster-reassignment.json
$ cat expand-cluster-reassignment.json
$ bin/kafka-reassign-partitions.sh --bootstrap-server "${KAFKA_BROKERS}" --command-config client.properties --reassignment-json-file expand-cluster-reassignment.json --execute
$ bin/kafka-reassign-partitions.sh --bootstrap-server "${KAFKA_BROKERS}" --command-config client.properties --reassignment-json-file expand-cluster-reassignment.json --verify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment