kafka运维--增加topic备份因子

上篇文章将了怎样优化kafka配置,其中提到了kafka集群topic的默认备份因子参数default.replication.factor。

如果想针对某一个或者多个topic,增加备份因子参照下面步骤进行。


1. 创建一个需要增加备份因子的topic列表的文件,文件格式是json格式的(跟【kafka运维--集群扩容后手动Rebalance topic】文章中rebalance topic时创建的topic 列表文件是一样的)。

topic.conf.multi

{"topics": [{"topic": "topic1"},
            {"topic": "topic2"},
 "version":1
}

2. 使用kafka官方提供的工具拿到上面topic的partions 分布情况,并重定向到文件中。


kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topic.conf.multi --broker-list 0,1,2,3,4  --generate > ressgintopic.conf

3. 修改ressgintopic.conf 文件的,手动分配新增加的partion 备份因子。

ressgintopic.conf

{
    "version": 1,
    "partitions": [
        {
            "topic": "topic1",
            "partition": 0,
            "replicas": [
                7,
                1,
                2
            ]
        },
        {
            "topic": "topic1",
            "partition": 1,
            "replicas": [
                8,
                2,
                3
            ]
        },
        {
            "topic": "topic1",
            "partition": 2,
            "replicas": [
                9,
                3,
                4
            ]
        }
    ]
}

4. 通过下面命令执行备份因子扩容过程

 bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file ressgintopic.conf --execute

5. 查看扩容进度。

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file ressgintopic.conf  --verify


参考资料:http://kafka.apache.org/documentation/#configuration


你可能感兴趣的:(原创,大数据系统运维笔记,Kafka,环境搭建,大数据,笔记,运维)