本篇內(nèi)容介紹了“怎么設(shè)定master特性”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)公司成都網(wǎng)站建設(shè)按需搭建網(wǎng)站,是成都網(wǎng)站設(shè)計(jì)公司,為輕質(zhì)隔墻板提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計(jì)服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計(jì)、前端HTML5制作、后臺(tái)程序開(kāi)發(fā)等。成都網(wǎng)站建設(shè)熱線:028-86922220
9特殊考慮
9.1 Licensing
任何時(shí)候,我們都鼓勵(lì)開(kāi)發(fā)者使用GPL (GNU GeneralPublic License) 2.0 或者更新的版本。shell庫(kù)函數(shù)不嚴(yán)格限制于此,它是基于LGPL( GNU Lesser General Public License)版本2.1 或更新版本的,這樣non-GPL的資源的代理可以使用。
資源代理必須在源代碼顯式的標(biāo)明其授權(quán)信息。
9.2本地設(shè)定
當(dāng)運(yùn)行 .ocf-shellfuncs(4.3節(jié)初始化有說(shuō)明),資源代理自動(dòng)設(shè)定LANG 和 LC_ALL到C的區(qū)域設(shè)置。資源代理可以期待總是在C的區(qū)域設(shè)置里操作,不需要重置LANG和LC_ 環(huán)境變量。
9.3測(cè)試運(yùn)行進(jìn)程
測(cè)試一個(gè)指定的進(jìn)程(知道進(jìn)程id)是否正在運(yùn)行,通常的做法是發(fā)送一個(gè)0信號(hào)并捕獲錯(cuò)誤。比如:
1 2 3 4 5 6 | if kill -s 0 `cat $daemon_pid_file`; then ocf_log debug "Process is currently running" else ocf_log warn "Process is dead, removing pid file" rm -f $daemon_pid_file if |
重要:一種遠(yuǎn)優(yōu)于上述做法的例子是使用一個(gè)守護(hù)進(jìn)程的客戶端調(diào)用一個(gè)守護(hù)進(jìn)程的功能,如5.3節(jié) monitor action的例子。
9.4設(shè)定master特性
有狀態(tài)(master/slave)資源必須設(shè)定其自己的master特性,這些特性會(huì)為集群管理提供一些信息,幫助它確定誰(shuí)是最合適提升為master角色的節(jié)點(diǎn)。
重要:多個(gè)實(shí)例擁有相同的master特性是可以接受的。在那個(gè)例子中,集群資源管理器可以自動(dòng)選擇一個(gè)資源代理去提升為master角色。如果所有的實(shí)例都有缺省的master分值0的話,集群管理器不提升任何實(shí)例。這樣,重要的是,至少保持一個(gè)實(shí)例的master分值為正。
為此目標(biāo),crm_master 比較方便。它封裝了crm_attribute來(lái)設(shè)置其運(yùn)行節(jié)點(diǎn)上的屬性 master-$OCF_RESOURCE_INSTANCE為一個(gè)特定的值。集群管理器會(huì)將相應(yīng)實(shí)例的這些改變轉(zhuǎn)換為提升分?jǐn)?shù),其提升的特征基于此。
有狀態(tài)的資源代理在monitor和notity行為時(shí)執(zhí)行crm_master。
下面的例子假設(shè)foobar資源代理可以通過(guò)執(zhí)行一個(gè)有返回值的執(zhí)行文件測(cè)試應(yīng)用的狀態(tài)。這個(gè)返回值取決于是否:
資源是master角色或者是slave角色(被master完全捕獲),或者
資源是slave角色,但是因?yàn)楫惒綇?fù)制的原因,落后于master,或者
資源安全的停止了,或者
資源意外地失效了
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | foobar_monitor() { local rc # exit immediately if configuration is not valid foobar_validate_all || exit $? ocf_run frobnicate --test # This example assumes the following exit code convention # for frobnicate: # 0: running, and fully caught up with master # 1: gracefully stopped # 2: running, but lagging behind master # any other: error case "$?" in 0) rc=$OCF_SUCCESS ocf_log debug "Resource is running" # Set a high master preference. The current master # will always get this, plus 1. Any current slaves # will get a high preference so that if the master # fails, they are next in line to take over. crm_master -l reboot -v 100 ;; 1) rc=$OCF_NOT_RUNNING ocf_log debug "Resource is not running" # Remove the master preference for this node crm_master -l reboot -D ;; 2) rc=$OCF_SUCCESS ocf_log debug "Resource is lagging behind master" # Set a low master preference: if the master fails # right now, and there is another slave that does # not lag behind the master, its higher master # preference will win and that slave will become # the new master crm_master -l reboot -v 5 ;; *) ocf_log err "Resource has failed" exit $OCF_ERR_GENERIC esac return $rc } |
“怎么設(shè)定master特性”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
分享文章:怎么設(shè)定master特性
本文URL:http://www.yijiale78.com/article14/pehjge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、商城網(wǎng)站、自適應(yīng)網(wǎng)站、響應(yīng)式網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)