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

本文介绍了如何在Kafka集群中针对特定Topic增加备份因子。操作步骤包括创建一个包含需要调整的Topic列表的JSON文件,类似于之前集群扩容后的手动Rebalance过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

上篇文章将了怎样优化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


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值