修改topic分区数和副本数

Partitions只能增加(扩容)

 bin/kafka-topics.sh --alter --zookeeper localhost:42182 --topic myboys1 --partitions 2

 

修改备份数量

./kafka-reassign-partitions.sh --zookeeper localhost:42182  --reassignment-json-file  ../partitions-extension-push-token-topic.json --execute

 

这个文件自己创建,格式按照下面的格式就可以了,执行完可删除。

partitions-extension-push-token-topic.json文件配置

{

        "partitions":

                [

                {

                        "topic": "myboys1",

                        "partition": 0,

                        "replicas": [1,2]    //指定副本所在brokerID

                },

                {

                        "topic": "myboys1",

                        "partition": 1,

                        "replicas": [2,3]

                },

                {

                        "topic": "myboys1",

                        "partition": 2,

                        "replicas": [1,3]

                }

                ],

        "version":1

}

 

同样我们可以使用verify参数来检查上面的执行计划是否完成,如下:

./kafka-reassign-partitions.sh --zookeeper localhost:42182  --reassignment-json-file  ../partitions-extension-push-token-topic.json --verify

 

你可能感兴趣的:(kafka)