在新版本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