您好,登錄后才能下訂單哦!
這篇文章主要講解了“akka cluster相關(guān)問(wèn)題怎么解決”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“akka cluster相關(guān)問(wèn)題怎么解決”吧!
最近項(xiàng)目中,用akka(2.6.8) cluster在k8s做分布式的部署,,其中遇到unreachable node 如果一直未手動(dòng)重啟,則會(huì)導(dǎo)致其他的node加入不到cluster中來(lái),
具體的操作為其中的一個(gè)非seed node節(jié)點(diǎn)由于pod 重啟導(dǎo)致,部署到了其他的節(jié)點(diǎn)上,而之前的node(ip),cluster則會(huì)一直去連接該node(ip),從而導(dǎo)致異常
首先我們先看一下概念Gossip Convergence,如下:
Gossip convergence cannot occur while any nodes are unreachable. The nodes need to become reachable again, or moved to the down and removed states (see the Cluster Membership Lifecycle section). This only blocks the leader from performing its cluster membership management and does not influence the application running on top of the cluster. For example this means that during a network partition it is not possible to add more nodes to the cluster. The nodes can join, but they will not be moved to the up state until the partition has healed or the unreachable nodes have been downed.
翻譯過(guò)來(lái)就是: 當(dāng)任何節(jié)點(diǎn)都不可達(dá)時(shí),Gossip convergence就不達(dá)成一致。節(jié)點(diǎn)需要再次變得reachable,或轉(zhuǎn)移到down和removed狀態(tài)。這僅阻止領(lǐng)導(dǎo)者執(zhí)行其集群成員資格管理,并且不會(huì)影響在集群頂部運(yùn)行的應(yīng)用程序。例如,這意味著在網(wǎng)絡(luò)分
區(qū)期間不可能將更多節(jié)點(diǎn)添加到群集。節(jié)點(diǎn)可以加入,但在分區(qū)修復(fù)或無(wú)法訪問(wèn)的節(jié)點(diǎn)已關(guān)閉之前,它們將不會(huì)移入up狀態(tài)。
很明顯,akka就是要保證每個(gè)節(jié)點(diǎn)是reachable或者down,這樣才能進(jìn)行一致性協(xié)商
membership-lifecycle也有提到:
If a node is unreachable then gossip convergence is not possible and therefore most leader actions are impossible (for instance, allowing a node to become a part of the cluster). To be able to move forward, the node must become reachable again or the node must be explicitly “downed”. This is required because the state of an unreachable node is unknown and the cluster cannot know if the node has crashed or is only temporarily unreachable because of network issues or GC pauses. See the section about User Actions below for ways a node can be downed.
也就是說(shuō),如果一個(gè)節(jié)點(diǎn)是unreachable的,必須保證節(jié)點(diǎn)是reachable或者downed狀態(tài),因?yàn)閡nreachable狀態(tài)也有可能是網(wǎng)絡(luò)抖動(dòng),或者GC導(dǎo)致服務(wù)器負(fù)載過(guò)高引起的,這些狀態(tài)akka無(wú)法分辨,只能無(wú)限的進(jìn)行重連
既然有了問(wèn)題,問(wèn)題咱們就得解決,解決方法自然就可以去官網(wǎng)解決,通過(guò)把unreachable節(jié)點(diǎn)自動(dòng)的轉(zhuǎn)化為down狀態(tài)
以http請(qǐng)求的形式,主動(dòng)的進(jìn)行狀態(tài)轉(zhuǎn)化
引入split-brain-resolver(SBR)
第一種方式自行研究,我們采用第二種方式: 其中SBR分tatic-quorum, keep-majority, keep-oldest, down-all, lease-majority 五種strategies
我們采用keep-majority策略,其中五種策略的優(yōu)缺點(diǎn)以及使用場(chǎng)景自行通過(guò)官網(wǎng)strategies進(jìn)行分析
我們看一下keep-majority策略下的akka配置
akka.coordinated-shutdown.exit-jvm = on akka.coordinated-shutdown.exit-code = 0 akka.cluster.downing-provider-class = "akka.cluster.sbr.SplitBrainResolverProvider" akka.cluster.split-brain-resolver.down-all-when-unstable = off akka.cluster.split-brain-resolver.stable-after = 20s akka.cluster.split-brain-resolver.active-strategy = keep-majority akka.cluster.split-brain-resolver.keep-majority.role = "admin"
名詞 | 說(shuō)明 |
---|---|
akka.coordinated-shutdown.exit-jvm | 當(dāng)節(jié)點(diǎn)從cluster中移除時(shí),是否退出jvm,可選為on off |
akka.coordinated-shutdown.exit-code | 退出時(shí)的狀態(tài)碼 |
akka.cluster.downing-provider-class | 配置為akka.cluster.sbr.SplitBrainResolverProvider,表示啟動(dòng)SBR |
akka.cluster.split-brain-resolver.down-all-when-unstable | 當(dāng)cluster處于不穩(wěn)定狀態(tài)多久,會(huì)關(guān)閉所有節(jié)點(diǎn),可選on off或者持續(xù)時(shí)間,如15s |
akka.cluster.split-brain-resolver.stable-after | 節(jié)點(diǎn)處于unreachable多久,SBR開始進(jìn)行節(jié)點(diǎn)down操作 |
akka.cluster.split-brain-resolver.active-strategy | keep-majority,啟動(dòng)的策略 |
akka.cluster.split-brain-resolver.keep-majority.role | 設(shè)置只有該role才能進(jìn)行做SBR決定 |
注意:對(duì)于akka.cluster.split-brain-resolver.keep-majority.role,如果cluster由于其他原因,導(dǎo)致只存在少數(shù)節(jié)點(diǎn)(小于集群節(jié)點(diǎn)的一半),而該少數(shù)節(jié)點(diǎn)的role剛好等于該值,則該少數(shù)節(jié)點(diǎn)不會(huì)退出,
如果不配置該項(xiàng),則少數(shù)節(jié)點(diǎn)就會(huì)全部退出,從而導(dǎo)致整個(gè)集群down
感謝各位的閱讀,以上就是“akka cluster相關(guān)問(wèn)題怎么解決”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)akka cluster相關(guān)問(wèn)題怎么解決這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。