aboutsummaryrefslogtreecommitdiffstats
path: root/kafka
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-04-24 13:35:53 -0700
committerBryan Newbold <bnewbold@archive.org>2020-04-24 13:35:53 -0700
commita7463089f2c5297d73bf141225a4d8f1af591890 (patch)
treec853c09cf4bbed366d66215536f95074938540d2 /kafka
parent5ec0e13b9870496b6316c7f7eaba4e4da71e9082 (diff)
downloadsandcrawler-a7463089f2c5297d73bf141225a4d8f1af591890.tar.gz
sandcrawler-a7463089f2c5297d73bf141225a4d8f1af591890.zip
kafka: how to rebalance parititions between brokers
Diffstat (limited to 'kafka')
-rw-r--r--kafka/howto_rebalance.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/kafka/howto_rebalance.md b/kafka/howto_rebalance.md
new file mode 100644
index 0000000..06ae507
--- /dev/null
+++ b/kafka/howto_rebalance.md
@@ -0,0 +1,29 @@
+
+## Rebalance Storage Between Brokers
+
+For example, after adding or removing brokers from the cluster.
+
+Create a list of topics to move, and put it in `/tmp/topics_to_move.json`:
+
+ {
+ "version": 1,
+ "topics": [
+ {"topic": "sandcrawler-shadow.grobid-output"},
+ {"topic": "fatcat-prod.api-crossref"}
+ ]
+ }
+
+On a kafka broker, go to `/srv/kafka-broker/kafka-*/bin`, generate a plan, then
+inspect the output:
+
+ ./kafka-reassign-partitions.sh --zookeeper localhost:2181 --broker-list "280,281,284,285,263" --topics-to-move-json-file /tmp/topics_to_move.json --generate > /tmp/reassignment-plan.json
+ cat /tmp/reassignment-plan.json | rg '^\{' | tail -n1 > /tmp/new-plan.json
+ cat /tmp/reassignment-plan.json | rg '^\{' | jq .
+
+If that looks good, start the rebalance:
+
+ ./kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file /tmp/new-plan.json --execute
+
+Then monitor progress:
+
+ ./kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file /tmp/new-plan.json --verify