Kafka 优化参数 unclean.leader.election.enable
Kafka 某個節點掛掉,導致整個服務異常,為了保證服務容災,可對下面幾個參數進行調整
?
unclean.leader.election.enable=true min.insync.replicas=1 offsets.topic.replication.factor=3?
這三個配置什么意思呢? 依次來看一下:
-
unclean.leader.election.enable
?
官方描述:
Indicates whether to enable replicas not in the ISR set to be selected as leader as a last resort, even though doing so may result in data loss。
?
解釋:該字段默認值為False。默認情況下leader不能從非ISR的副本列表里選擇;因為在非ISR副本列表里選擇leader,很有可能會導致部分數據丟失。既然這樣,那為什么還要打開這個字段呢?因為在很異常情況下,比如ISR內的副本都不可用了,此時如果該字段設置為False,服務會直接掛掉;如果該字段設為True,即允許從非ISR列表中選擇leader,那么服務盡管有可能丟失數據,卻依然可以繼續使用。所以這個參數必須參考業務特性來決定是否打開。
?
-
min.insync.replicas
?
官方描述:
When a producer sets acks to "all" (or "-1"), min.insync.replicas specifies the minimum number of replicas that must acknowledge a write for the write to be considered successful。
?
解釋:該字段默認值為1。上述英文翻譯為:表示當在acks=-1時,最少有一個Replica進行確認回執,才確認數據寫入成功。這個參數在集群搭建時,為了保證數據的完整性,經常會被改為2。這里改為1的原因是:在只有一個副本在工作 、其他都掛掉的極端情況下,保證客戶端能夠正常提供服務。如果設置為2,當只有一個副本在工作的時候,就會出現生產端一直生產失敗的情況,會影響業務。
?
-
offsets.topic.replication.factor
?
官網描述:
The replication factor for the offsets topic (set higher to ensure availability). Internal topic creation will fail until the cluster size meets this replication factor requirement.
?
解釋:該值默認為1。表示kafka的內部topic consumer_offsets副本數。當該副本所在的broker宕機,consumer_offsets只有一份副本,該分區宕機。使用該分區存儲消費分組offset位置的消費者均會收到影響,offset無法提交,從而導致生產者可以發送消息但消費者不可用。所以需要設置該字段的值大于1。
?
查閱相關資料:
https://blog.csdn.net/u013256816/article/details/80790185
騰訊云中間件 公眾號
?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Kafka 优化参数 unclean.leader.election.enable的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: APC异步过程调用
- 下一篇: CDH 5.13.0 集成 Phoeni