用kafka-reassign-partitions.sh写一份JSON计划,把上一篇里卡着死掉broker的两个分区真实迁移到健康的broker上,看--execute和--verify两步真实分别做了什么。
命令 · shell $ cat reassign-plan.json { "version": 1, "partitions": [ {"topic": "after-join-topic", "partition": 0, "replicas": [1, 2]}, {"topic": "after-join-topic", "partition": 3, "replicas": [3, 2]} ] } $ kafka-reassign-partitions.sh --bootstrap-server localhost:19092 \ --reassignment-json-file reassign-plan.json --execute
Current partition replica assignment
{"partitions":[{"topic":"after-join-topic","partition":0,"replicas":[4,1],...},
{"topic":"after-join-topic","partition":3,"replicas":[3,4],...}]}
Successfully started partition reassignments for after-join-topic-0,after-join-topic-3执行之前,工具真实先把"当前的分配"原样打印了一遍——这份输出真实就是回滚用的,如果新计划真实出了问题,把这段JSON存下来再跑一次--execute就能真实退回去。
命令 · shell $ kafka-reassign-partitions.sh --bootstrap-server localhost:19092 \ --reassignment-json-file reassign-plan.json --verify
Status of partition reassignment: Reassignment of partition after-join-topic-0 is completed. Reassignment of partition after-join-topic-3 is completed. Clearing broker-level throttles on brokers 1,2,3 Clearing topic-level throttles on topic after-join-topic
真实describe一下这个topic现在的状态:
Partition 0 Leader: 1 Replicas: 1,2 Isr: 1,2 ← 死掉的4真实被换成了2 Partition 1 Leader: 1 Replicas: 1,2 Isr: 1,2 Partition 2 Leader: 2 Replicas: 2,3 Isr: 2,3 Partition 3 Leader: 3 Replicas: 3,2 Isr: 2,3 ← 死掉的4真实被换成了2
每一步都是本文上面用kafka-reassign-partitions.sh跑出来的原始结果。