半兽人 发表于: 2015-03-10   最后更新时间: 2016-04-07  
  •   267 订阅,7381 游览


Increasing the replication factor of an existing partition is easy. Just specify the extra replicas in the custom reassignment json file and use it with the --execute option to increase the replication factor of the specified partitions.

在现有分区增加副本是很容易的,只要指定自定义的重新分配的json文件脚本,并用 --execute 选项去执行这个脚本。

For instance, the following example increases the replication factor of partition 0 of topic foo from 1 to 3. Before increasing the replication factor, the partition's only replica existed on broker 5. As part of increasing the replication factor, we will add more replicas on brokers 6 and 7.


The first step is to hand craft the custom reassignment plan in a json file-

第一步手工写一个自定义的分配的json脚本 -

> cat increase-replication-factor.json

Then, use the json file with the --execute option to start the reassignment process-


> bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --execute
Current partition replica assignment


Save this to use as the --reassignment-json-file option during rollback
Successfully started reassignment of partitions

The --verify option can be used with the tool to check the status of the partition reassignment. Note that the same increase-replication-factor.json (used with the --execute option) should be used with the --verify option

-- version 选项来验证parition分配的状态。注意,使用同样的 increase-replication-factor.json

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --verify
Status of partition reassignment:
Reassignment of partition [foo,0] completed successfully

You can also verify the increase in replication factor with the kafka-topics tool-


> bin/kafka-topics.sh --zookeeper localhost:2181 --topic foo --describe
Topic:foo	PartitionCount:1	ReplicationFactor:3	Configs:
	Topic: foo	Partition: 0	Leader: 5	Replicas: 5,6,7	Isr: 5,6,7

发表于: 1年前   最后更新时间: 1年前   游览量:7381
上一条: kafka退役broker
下一条: kafka彻底删除topic


  • 评论…
    • in this conversation