在新版本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文件
[[email protected]_65_10_centos bin]# ./kafka-reassign-partitions.sh --zookeeper xxx:2181,xxx:2182,xxx:2183 --reassignment-json-file 1.json --execute
1.4 验证执行计划结果
[[email protected]_65_10_centos bin]# ./kafka-reassign-partitions.sh --zookeeper xxx:2181,xxx:2182,xxx:2183 --reassignment-json-file 1.json --verify
1.5 查看新的副本数量
[[email protected]_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