首页 > 其他 > 详细

kafka Reassign Partitions Tool

时间:2015-07-03 02:10:03      阅读:282      评论:0      收藏:0      [点我收藏+]

kafka 0.8增加了重新分配partition功能,进行扩容

kafka-reassign-partitions.sh脚本

?

Option ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description ? ? ? ? ? ? ? ? ? ? ? ? ? ?

------ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?----------- ? ? ? ? ? ? ? ? ? ? ? ? ? ?

--broker-list <brokerlist> ? ? ? ? ? ? ?The list of brokers to which the ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? partitions need to be reassigned in ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? the form "0,1,2". This is required ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if --topics-to-move-json-file is ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? used to generate reassignment ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? configuration ? ? ? ? ? ? ? ? ? ? ? ?

--execute ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Kick off the reassignment as specified?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? by the --reassignment-json-file ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? option. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

--generate ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Generate a candidate partition ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? reassignment configuration. Note ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? that this only generates a candidate?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? assignment, it does not execute it. ?

--reassignment-json-file <manual ? ? ? ?The JSON file with the partition ? ? ??

? assignment json file path> ? ? ? ? ? ? ?reassignment configurationThe format?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? to use is - ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {"partitions": ? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [{"topic": "foo", ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "partition": 1, ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "replicas": [1,2,3] }], ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "version":1 ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

--topics-to-move-json-file <topics to ? Generate a reassignment configuration ?

? reassign json file path> ? ? ? ? ? ? ? ?to move the partitions of the ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? specified topics to the list of ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? brokers specified by the --broker- ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? list option. The format to use is - ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {"topics": ? ? ? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [{"topic": "foo"},{"topic": "foo1"}],?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "version":1 ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

--verify ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Verify if the reassignment completed ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? as specified by the --reassignment- ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? json-file option. ? ? ? ? ? ? ? ? ? ?

--zookeeper <urls> ? ? ? ? ? ? ? ? ? ? ?REQUIRED: The connection string for ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? the zookeeper connection in the form?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? host:port. Multiple URLS can be ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? given to allow fail-over. ??

?

?

narkhed$ cat partitions-to-move.json ?

?{"partitions":

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [{"topic": "foo",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "partition": 1,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "replicas": [1,2,3] }],

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "version":1

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }

? ??

? ??

? ??

bin/kafka-reassign-partitions.sh --topics-to-move-json-file dirk_topic_move.json ?--zookeeper host34/kafka-dirktest --broker-list "0341,0361" --generate

生成将topic dirkzhang放到341和361上的json,用json执行execute就可以了

Current partition replica assignment

?

{"version":1,"partitions":[{"topic":"dirkzhang","partition":6,"replicas":[361,371]},{"topic":"dirkzhang","partition":0,"replicas":[361,371]},{"topic":"dirkzhang","partition":5,"replicas":[341,371]},{"topic":"dirkzhang","partition":4,"replicas":[371,361]},{"topic":"dirkzhang","partition":3,"replicas":[361,341]},{"topic":"dirkzhang","partition":7,"replicas":[371,341]},{"topic":"dirkzhang","partition":1,"replicas":[371,341]},{"topic":"dirkzhang","partition":2,"replicas":[341,361]}]}

?

Proposed partition reassignment configuration

?

{"version":1,"partitions":[{"topic":"dirkzhang","partition":6,"replicas":[361,341]},{"topic":"dirkzhang","partition":5,"replicas":[341,361]},{"topic":"dirkzhang","partition":0,"replicas":[361,341]},{"topic":"dirkzhang","partition":4,"replicas":[361,341]},{"topic":"dirkzhang","partition":3,"replicas":[341,361]},{"topic":"dirkzhang","partition":1,"replicas":[341,361]},{"topic":"dirkzhang","partition":7,"replicas":[341,361]},{"topic":"dirkzhang","partition":2,"replicas":[361,341]}]} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?----------------------------------------------------------------- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

bin/kafka-reassign-partitions.sh --zookeeper host34/kafka-dirktest --reassignment-json-file dirk_move_partition.json --execute

将partition0,1的replica放到341,371上(brokerid前边不能有零,是int)

dirk_move_partition.json:

{"version":1,"partitions":

[{"topic":"dirkzhang",

? "partition":0,

? "replicas":[341,371]

},

{"topic":"dirkzhang",

"partition":1,

"replicas":[341,371]

}]

}

?

------------------------------------------------

用verify检查是否迁移成功

bin/kafka-reassign-partitions.sh --reassignment-json-file dirk_move_partition.json ?--zookeeper host34/kafka-dirktest --verify

Status of partition reassignment:

Reassignment of partition [dirkzhang,1] completed successfully

?

?

?

kafka Reassign Partitions Tool

原文:http://blackproof.iteye.com/blog/2223879

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!