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 ) !

相关推荐
Lansonli4 小时前
大数据Spark(九十五):Spark Shuffle 参数调优全解析
大数据·分布式·spark
Nefu_lyh19 小时前
【Spark】05Spark 数据读取与保存:文件格式、文件系统与结构化数据
大数据·分布式·spark
云边有个稻草人1 天前
集中式与分布式怎么选?谈谈金仓数据库的架构取舍
分布式·国产数据库·架构选型·金仓数据库·集中式数据库·企业级数据库·核心业务系统
东风微鸣1 天前
QuePaxa VS Raft:广域网共识,为什么「慢但不停」胜过「快但一抖就死」
分布式·云原生·raft
wdf80881 天前
面向大规模科学数据可视化的ParaView分布式架构优化与UltraLAB高性能计算平台适配研究
分布式·信息可视化·架构·paraview
崖边看雾1 天前
Kafka 手册
分布式·面试·kafka
starzy19902 天前
Structured Streaming Kafka Sink:写出一条生产级的回流链路
大数据·分布式·spark·kafka
国科安芯2 天前
编队不是多放几颗星:分布式雷达与编队飞行任务中星内协同网络的确定性时序
网络·分布式·fpga开发·架构·低轨卫星·抗辐射
AllData公司负责人3 天前
实战一:AllData大模型与AI数据底座-数据传输平台-DBSyncer,搭建 File 到 Doris 高效数据同步链路,批量文件离线入仓
数据库·人工智能·分布式·大模型·数据传输·数据同步·连接器
starzy19903 天前
Structured Streaming 集成 Kafka 实现:读写路径、位点语义与生产调优
大数据·分布式·spark·kafka