标签:apache kafka迁移与扩容 kafka迁移与扩容 kafka扩容 kafka新增分区 kafka迁移topic
参考官网site:https://cwiki.apache.org/confluence/display/KAFKA/Replication+tools#Replicationtools-6.ReassignPartitionsTool
说明:
当我们对kafka集群扩容时,需要满足2点要求:
脚本migration-push-token-topic.json文件内容如下:
{
"topics":
[
{
"topic": "push-token-topic"
}
],
"version":1
}
lizhitao@localhost:$ ./bin/kafka-reassign-partitions.sh --zookeeper 192.168.2.225:2183/config/mobile/mq/mafka
--reassignment-json-file replicas-update-push-token-topic.json --execute
假如初始时push-token-topic为一个副本,为了提高可用性,需要改为2副本模式。
脚本replicas-push-token-topic.json文件内容如下:
{
"partitions":
[
{
"topic": "log.mobile_nginx",
"partition": 0,
"replicas": [101,102,104]
},
{
"topic": "log.mobile_nginx",
"partition": 1,
"replicas": [102,103,106]
},
{
"topic": "xxxx",
"partition": 数字,
"replicas": [数组]
}
],
"version":1
}
a.先扩容分区数量,脚本如下:
例如:push-token-topic初始分区数量为12,目前到增加到15个
lizhitao@localhost:$ ./bin/kafka-topics.sh --zookeeper 192.168.2.225:2183/config/mobile/mq/mafka --alter --partitions 15 --topic push-token-topic
b.设置topic分区副本
lizhitao@localhost:$ ./bin/kafka-reassign-partitions.sh --zookeeper 192.168.2.225:2183/config/mobile/mq/mafka
--reassignment-json-file partitions-extension-push-token-topic.json --execute
脚本partitions-extension-push-token-topic.json文件内容如下:
{ "partitions": [ { "topic": "push-token-topic", "partition": 12, "replicas": [101,102] }, { "topic": "push-token-topic", "partition": 13, "replicas": [103,104] }, { "topic": "push-token-topic", "partition": 14, "replicas": [105,106] } ], "version":1 }
apache kafka迁移与扩容工具用法,布布扣,bubuko.com
标签:apache kafka迁移与扩容 kafka迁移与扩容 kafka扩容 kafka新增分区 kafka迁移topic
原文地址:http://blog.csdn.net/lizhitao/article/details/33344597