kafka-新增topic副本数

一. 简述:

在 Kafka 中增加主题(Topic)的副本数可以提高数据的可靠性和容错能力。在创建topic时,如果设置的不合理,或者创建后有新的需求变动,就需要调整了。

二. 方法:

可通过官方的指令:kafka-reassign-partitions.sh

  1. 通过kafka-topics.sh 脚本查看topic信息。

    #./kafka-topics.sh --describe --bootstrap-server kafka-server:9092 --topic xxxx_heart_ping

    Topic: xxxx_heart_ping PartitionCount: 12 ReplicationFactor: 3 Configs: min.insync.replicas=2,message.format.version=2.6-IV0,unclean.leader.election.enable=true
    Topic: xxxx_heart_ping Partition: 0 Leader: 4 Replicas: 4,8 Isr: 4,8
    Topic: xxxx_heart_ping Partition: 1 Leader: 8 Replicas: 8,6 Isr: 8,6
    Topic: xxxx_heart_ping Partition: 2 Leader: 6 Replicas: 6,9 Isr: 9,6

  2. 不动原有的副本配置,新增一个第三副本(json文件方式):

    #cat increase-replication-factor.json
    {"version":1,
    "partitions":[
    {"topic":"xxxx_heart_ping","partition":0,"replicas":[4,8,5]},
    {"topic":"xxxx_heart_ping","partition":1,"replicas":[8,6,7]},
    {"topic":"xxxx_heart_ping","partition":2,"replicas":[6,9,4]},
    ]}

  3. 通过kafka-reassign-partitions.sh 重新分配数据:

    /kafka-reassign-partitions.sh --bootstrap-server kafka-server:9092 --reassignment-json-file increase-replication-factor.json --execute

  4. 可通过--verify查看分配进度:

    /kafka-reassign-partitions.sh --bootstrap-server kafka-server:9092 --reassignment-json-file increase-replication-factor.json --verify


深耕运维行业多年,擅长linux、容器云原生、运维自动化等方面。

承接各类运维环境部署、方案设计/实施、服务代运维工作,欢迎沟通交流!

(V: xiaoxiangbj2013 ) !

相关推荐
ANYOLY5 小时前
分布式面试题库
分布式·面试·职场和发展
i***665010 小时前
分布式推理框架 xDit
分布式
哈哈哈笑什么11 小时前
分布式事务实战:订单服务 + 库存服务(基于本地消息表组件)
分布式·后端·rabbitmq
哈哈哈笑什么11 小时前
完整分布式事务解决方案(本地消息表 + RabbitMQ)
分布式·后端·rabbitmq
LDG_AGI11 小时前
【推荐系统】深度学习训练框架(十):PyTorch Dataset—PyTorch数据基石
人工智能·pytorch·分布式·python·深度学习·机器学习
tanxiaomi11 小时前
Redisson分布式锁 和 乐观锁的使用场景
java·分布式·mysql·面试
熊文豪14 小时前
【前瞻创想】Kurator:站在巨人肩膀上的分布式云原生创新实践
分布式·云原生·kurator
问道飞鱼15 小时前
【分布式知识】Redis-Shake 容器云部署完整指南
redis·分布式·redis-shake
milanyangbo17 小时前
从硬盘I/O到网络传输:Kafka与RocketMQ读写模型及零拷贝技术深度对比
java·网络·分布式·架构·kafka·rocketmq
GEM的左耳返17 小时前
Java面试实战:从Spring Boot到AI集成的技术深度挑战
spring boot·redis·微服务·kafka·java面试·spring ai·缓存优化