kafka动态修改__consumer_offsets的副本数量(无需重启服务)

在新版本Kafka中,__consumer_offsets这个topic是存放消费者偏移量的,但是该主题默认配置副本数量只有1,容易造成单点故障,我们可以动态修改(无需重启服务)副本因子,提高kafka的可靠性

修改流程

1、编写执行计划的json文件

1.1 动态地增加相关主题的副本数非常的简单,同样是使用kafka-reassign-partitions.sh工具来执行,所以我们在操作之前得准备一个Json文件,里面详细地记录着每个分区的副本所在机器等信息,具体如下:

{
    "version": 1, 
    "partitions": [
        {
            "topic": "__consumer_offsets", 
            "partition": 0, 
            "replicas": [
                1, 
                2
            ]
        },
        {
            "topic": "__consumer_offsets", 
            "partition": 1, 
            "replicas": [
                2, 
                3
            ]
        }
          ]
}

1.2 将json文件保存至linux中,并取名为1.json(任意名称)

vim replication.json

1.3 执行Json文件

[root@VM_65_10_centos bin]# ./kafka-reassign-partitions.sh --zookeeper xxx:2181,xxx:2182,xxx:2183 --reassignment-json-file 1.json --execute

1.4 验证执行计划结果

[root@VM_65_10_centos bin]# ./kafka-reassign-partitions.sh --zookeeper xxx:2181,xxx:2182,xxx:2183 --reassignment-json-file 1.json --verify

1.5 查看新的副本数量

[root@VM_65_10_centos bin]# ./kafka-topics.sh --zookeeper xxx:2181,xxx:2182,xxx:2183 --topic __consumer_offsets --describe

原文链接:
https://blog.csdn.net/alex_sheng_sea/article/details/84560859

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值