欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 资讯 > kafka-新增topic副本数

kafka-新增topic副本数

2025/7/30 18:29:35 来源:https://blog.csdn.net/gujimoxiao/article/details/145881811  浏览:    关键词: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_pingTopic: xxxx_heart_ping	PartitionCount: 12	ReplicationFactor: 3	Configs: min.insync.replicas=2,message.format.version=2.6-IV0,unclean.leader.election.enable=trueTopic: xxxx_heart_ping	Partition: 0	Leader: 4	Replicas: 4,8	Isr: 4,8Topic: xxxx_heart_ping	Partition: 1	Leader: 8	Replicas: 8,6	Isr: 8,6Topic: 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 ) !

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词