kafka增加副本

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

增加副本


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.

增加副本之前,分区已存在的副本在broker5上,它也作为增加副本的一部分,我们将副本添加到broker6和7上。


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

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

> cat increase-replication-factor.json
{"version":1,
 "partitions":[{"topic":"foo","partition":0,"replicas":[5,6,7]}]}

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

然后,用--execute选项运行json脚本。

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

{"version":1,
 "partitions":[{"topic":"foo","partition":0,"replicas":[5]}]}

Save this to use as the --reassignment-json-file option during rollback
Successfully started reassignment of partitions
{"version":1,
 "partitions":[{"topic":"foo","partition":0,"replicas":[5,6,7]}]}

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-

你也可以使用kafka-topic工具验证-

> 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年前   游览量:5427
上一条: kafka退役broker
下一条: kafka彻底删除topic

评论…


  • 评论…
    • in this conversation
      提问