銈€偗銉嗐偅銉栨銇儑銉笺偪銉囥偅銈广偗銇屽銈屻仧銈夐亝婊炪仾銇忋儠銈с偆銉偑銉笺儛銇曘仜銈嬫柟娉

disk_crasher

DRBD銇с儑銈c偣銈晠闅溿倰妞滃嚭銇欍倠鏂规硶

DRBD銈掍娇銇c仧銈儵銈广偪銈枫偣銉嗐儬銇2鍙般伄銈点兗銉愩伀鍚屼竴銉囥兗銈裤亴鍚屾檪銇繚瀛樸仌銈屻倠銇熴倎銆併儑銈c偣銈亴鏁呴殰銇椼仸銈傘儑銉笺偪銈掑け銈忋仾銇勩仺銇勩亞銉°儶銉冦儓銇屻亗銈娿伨銇 (銈枫偋銈€兗銉夈儕銉冦偡銉炽偘銇ㄥ懠銇炽伨銇)銆傘倐銇椼儑銈c偣銈亴鏁呴殰銇椼仸銈傘偟銉笺儞銈广伅缍欑稓鍙兘銇с仚銇屻併仐銇嬨仐銈€偗銉嗐偅銉栨鍋淬伄銉囥偅銈广偗銇屽銈屻仧銇撱仺銇皸銇ャ亱銇亜銇俱伨閬嬬敤銈掔稓銇戙仸銇勩亸銈忋亼銇伅銇勩亶銇俱仜銈撱

DRBD銇≒acemaker銇ō瀹氥倰瑾挎暣銇欍倠銇ㄣ銈€偗銉嗐偅銉栨鍋淬伄銉囥偅銈广偗銇屾晠闅溿仐銇熴倝鑷嫊鐨勩伀銉曘偋銈ゃ儷銈兗銉愩仐銇︾鐞嗚呫伀銉°兗銉氱煡銇欍倠銇ㄣ亜銇嗐偄銈偡銉с兂銈掕嚜鍕曞寲銇欍倠銇撱仺銇屻仹銇嶃伨銇欍

浠ヤ笅銇併偄銈儐銈c儢鍋淬儑銉笺偪銉囥偅銈广偗鏁呴殰鏅傘伄鑷嫊銉曘偋銈ゃ儷銈兗銉愩倰瀹熺従銇欍倠銇熴倎銇ō瀹氥倰绱逛粙銇椼伨銇欍

DRBD銇≒acemaker銇悎銈忋仜鎶

蹇呰銇ō瀹氥伄瑕佺偣銇佷互涓嬨伄3銇ゃ仩銇戙仹銇欍

DRBD銇畂n-io-error銈抎etach銇仚銈
銇俱仛銆乨rbd.conf銇甦isk銈汇偗銈枫儳銉炽伀銇傘倠on-io-error銉戙儵銉°兗銈 銇ゃ倰detach銇ō瀹氥仐銇俱仚銆傘亾銇ゃ倰鎸囧畾銇椼仸銇娿亸銇ㄣ丏RBD銇岀鐞嗐仐銇︺亜銈嬨儑銈c偣銈亴澹娿倢銇熴仺銇嶃伀DRBD銇仢銇儑銈c偣銈倰鍒囥倞闆€仐銇俱仚銆傘儘銉冦儓銉兗銈帴缍氥伅鎸佺稓銇欍倠銇仹銆併儣銉┿偆銉炪儶鍋淬儑銈c偣銈亴澹娿倢銇熷牬鍚堛併仚銇广仸銇儑銈c偣銈疘/O銇璞°伅銈汇偒銉炽儉銉伌銇儑銈c偣銈伀銇倞銇俱仚銆
Pacemaker銇甦efault-resource-stickiness銈200銇仚銈
銇撱亾銇屻倐銇c仺銈傚ぇ鍒囥仾銉濄偆銉炽儓銇с仚銆Pacemaker銇甦efault-resource-stickiness銉椼儹銉戙儐銈c伅銆両NFINITY銈掕ō瀹氥仐銇︺亜銈嬫柟銇屽銇勩仹銇欍亴銆佷粖鍥炪伄鐩殑銈掗仈鎴愩仚銈嬨伀銇200銇仐銇︺亸銇犮仌銇勩侷NFINITY銇伨銇俱仹銇嚜鍕曘儠銈с偆銉偑銉笺儛銇岃捣銇撱倞銇俱仜銈撱
MailTo銉偨銉笺偣銈ㄣ兗銈搞偋銉炽儓銈掕拷鍔犮仚銈
DRBD銇倝銇炽伀Pacemaker銇併儠銈с偆銉偑銉笺儛鐧虹敓鏅傘伀銉偘銇閷层倰娈嬨仐銇俱仚銇屻併儭銉笺儷銇仼銇ч氱煡銇椼仸銇忋倢銇俱仜銈撱傘偗銉┿偣銈胯ō瀹氥伄涓伀MailTo銉偨銉笺偣銈ㄣ兗銈搞偋銉炽儓銈掕拷鍔犮仐銇︺亰銇忋仺銆併儠銈с偆銉偑銉笺儛銇岃捣銇嶃仧銇ㄣ亶銇儭銉笺儷銈掕嚜鍕曢佷俊銇с亶銈嬨倛銇嗐伀銇倞銇俱仚銆

銇仠default-resource-stickiness=INFINITY銇с伅銇勩亼銇亜銇亱

default-resource-stickiness銇併屽嫊浣溿仐銇︺亜銈嬨儶銈姐兗銈广仺銇濄伄銉偨銉笺偣銇屽嫊浣溿仐銇︺亜銈嬨儙銉笺儔銇祼銇炽仱銇嶃伄寮枫仌銆嶃倰绀恒仚銈广偝銈€仹銇欍傘亾銈屻倰INFINITY銇ō瀹氥仐銇︺仐銇俱亞銇ㄣ併偄銈儐銈c儢姗熶笂銇у嫊浣溿仐銇︺亜銈嬨儶銈姐兗銈广伅銆併儙銉笺儔鑷綋銇儉銈︺兂銈勩偑銉氥儸銉笺偪銇倛銈嬪垏銈婃浛銇堟搷浣滀互澶栥伄瑕佸洜銇с儠銈с偆銉偑銉笺儛銇椼仾銇忋仾銇c仸銇椼伨銇勩伨銇欍傘倐銇°倣銈撱併亾銇嫊銇嶈嚜浣撱伀鍟忛銇亗銈娿伨銇涖倱銇屻佸姽鏋溿亴寮枫仚銇庛伨銇欍

drbd銉偨銉笺偣銈ㄣ兗銈搞偋銉炽儓(drbd RA)銇併儮銉嬨偪銈掕銇嗐偪銈ゃ儫銉炽偘銇с屻儣銉┿偆銉炪儶銇仾銈嬨伖銇嶃偣銈炽偄銆嶃倰Pacemaker銇紳銇堛伨銇欍侾acemaker銇亾銇ゃ倰鑰冩叜銇椼仸銉偨銉笺偣銇厤缃倰姹哄畾銇椼伨銇欍傘亾銇撱仹銆乨efault-resource-stickiness銇孖NFINITY銇仾銇c仸銇勩倠銇ㄣ併儣銉┿偆銉炪儶銇仾銈嬨伖銇嶃偣銈炽偄鍊ゃ伅銆孖NTINITY锛嬪わ紳銉椼儵銈ゃ優銉嶃仺銇勩亞 Pacemaker銇垽鏂儷銉笺儷銇亰銇勩仸鐒℃剰鍛炽伀銇仯銇︺仐銇俱亜銇俱仚銆200銈掕ō瀹氥仚銈嬨仺銆乨rbd RA銇岃繑銇椼仧鍊ゃ倐銉椼儵銈ゃ優銉伄浣嶇疆姹恒倎銇弽鏄犮仌銈屻倠銈堛亞銇仾銈娿伨銇欍

瑷畾渚嬨仺鍕曚綔纰鸿獚鏂规硶

DRBD銈掍娇銇c仧HA銈儵銈广偪銈枫偣銉嗐儬銇屻亗銈屻伆銆佺垂浠嬨仐銇熻ō瀹氥伄鍔规灉銈掋仧銇犮仭銇⒑瑾嶃仹銇嶃伨銇欍傚嫊浣滅⒑瑾嶃伀浣裤仯銇熺挵澧冦伄瑷畾渚嬨倰绀恒仐銇俱仚銇仹銆併仈鍙傝冦亸銇犮仌銇勩傘倐銇°倣銈撱儧銈广儓鍚嶃両P銈€儔銉偣銆併儑銉愩偆銈瑰悕銇仼銇仼瀹滅疆銇嶆彌銇堛仸銇忋仩銇曘亜銆

drbd.conf

DRBD銉愩兗銈搞儳銉8.3鐢ㄣ伄瑷畾銇仾銇c仸銇勩伨銇欍8.4鐢ㄦ鏂囥伀銇仯銇︺亜銇俱仜銈撱亴銆侊紙浜掓彌鎬с亴銇傘倠銇仹锛8.4銇с倐銇撱伄銇俱伨銇у嫊銇忋伅銇氥仹銇欍傛渶浣庨檺銇儜銉┿儭銉笺偪銇椼亱鎸囧畾銇椼仸銇勩伨銇涖倱銆on-io-error detach;聽銇屻偔銉笺儩銈ゃ兂銉堛仹銇欍

global {
    usage-count no;
}

resource r0 {
    protocol C;
    syncer {
        rate 20M;
    }
    disk {
        on-io-error   detach;
    }
    device /dev/drbd0;
    disk   /dev/vg/lv01;
    on cluster1 {
        address 10.0.0.3:7788;
        meta-disk internal;
    }
    on cluster2 {
        address 10.0.0.4:7788;
        meta-disk internal;
    }
}

Pacemaker瑷畾

Web銈点兗銉愩伄HA銈儵銈广偪銈掓兂瀹氥仐銇︺亜銇俱仚銆傘倐銇c仺銈枫兂銉椼儷銇仐銇熴亼銈屻伆銆乤pache銆丗ilesystem銆両Paddr2銇仼銈掔渷鐣ャ仐銇︺倐銇勩亜銇ㄦ濄亜銇俱仚銆傘亾銇撱仹銇儩銈ゃ兂銉堛伅銆default-resource-stickiness="200"聽銇∕ailTo銉偨銉笺偣銈ㄣ兗銈搞偋銉炽儓銇椿鐢ㄣ仹銇欍傘仾銇奌eartbeat銇仧銈併伄ha.cf銇渷鐣ャ仐銇俱仚銆

property default-resource-stickiness="200" \
        no-quorum-policy="ignore" \
        stonith-enabled="false"
primitive alert ocf:heartbeat:MailTo \
        params email="root" subject="alert from webserver cluster" \
        op start interval="0" timeout="20" \
        op stop interval="0" timeout="20"
primitive drbd_r0 ocf:linbit:drbd \
        params drbd_resource="r0" \
        op monitor interval="20" role="Slave" timeout="40" \
        op monitor interval="10" role="Master" timeout="40" \
        op start interval="0" timeout="240" \
        op stop interval="0" timeout="100"
primitive httpd ocf:heartbeat:apache \
        params configfile="/etc/httpd/conf/httpd.conf" \
        op start interval="0" timeout="60" \
        op stop interval="0" timeout="90" \
        op monitor interval="20" timeout="30"
primitive mount ocf:heartbeat:Filesystem \
        params device="/dev/drbd0" fstype="ext4" directory="/h"
options="noatime" \
        op monitor interval="10" timeout="60" \
        op start interval="0" timeout="60" \
        op stop interval="0" timeout="60"
primitive vip ocf:heartbeat:IPaddr2 \
        params ip="10.30.101.6" cidr_netmask="16" \
        op monitor interval="30" timeout="60"
group webserver alert vip mount httpd
ms ms_drbd_r0 drbd_r0 \
        meta master-max="1" master-node-max="1" clone-max="2"
clone-node-max="1" notify="true"
location loc_webserver webserver 100: cluster1
colocation col_drbd_webserver inf: webserver ms_drbd_r0:Master
order ord_drbd_webserver inf: ms_drbd_r0:promote webserver:start

銈儵銈广偪銇捣鍕

cluster1銇╟luster2銇浮銈点兗銉愩仹heartbeat銈掕捣鍕曘仚銈嬨仺銆乧luster1銇屻偄銈儐銈c儢姗熴仺銇仯銇︺偗銉┿偣銈裤亴璧峰嫊銇椼伨銇欍俢rm_mon銈炽優銉炽儔銇у嫊浣滅姸鎱嬨倰琛ㄧず銇曘仜銈嬨仺銆佷互涓嬨伄銈堛亞銇嫊浣滅姸鎱嬨亴琛ㄧず銇曘倢銇俱仚銆

Online: [ cluster2 cluster1 ]

 Master/Slave Set: ms_drbd_r0
     Masters: [ cluster1 ]
     Slaves: [ cluster2 ]
 Resource Group: webserver
     alert      (ocf::heartbeat:MailTo):        Started cluster1
     vip        (ocf::heartbeat:IPaddr2):       Started cluster1
     mount      (ocf::heartbeat:Filesystem):    Started cluster1
     httpd      (ocf::heartbeat:apache):        Started cluster1

銈€偗銉嗐偅銉栨銇с亗銈媍luster1鍋淬仹cat /proc/drbd銈掑疅琛屻仚銈嬨仺銆佷互涓嬨伄銈堛亞銇嫊浣滅姸鎱嬨亴琛ㄧず銇曘倢銇俱仚銆

version: 8.3.1X (api:88/proto:86-97)
GIT-hash: dc4c32498e9cbf35734c4716b65ddd6fbd6e1eb4 build by
buildsystem@linbit, 2013-01-30 08:31:13
 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:1 nr:77773 dw:77774 dr:686 al:19 bm:48 lo:0 pe:0 ua:0 ap:0 ep:1
wo:f oos:0

銉兗銈儷銉囥偅銈广偗銇晠闅溿倰銈枫儫銉ャ儸銉笺儓銇欍倠鏂规硶

銈€偗銉嗐偅銉栨銇儹銉笺偒銉儑銈c偣銈亴澹娿倢銇熺姸娉併倰銈枫儫銉ャ儸銉笺儓銇欍倠銇伅銆乧luster1鍋淬仹娆°伄銈炽優銉炽儔銈掑疅琛屻仐銇俱仚銆

drbdadm detach r0

cat /proc/drbd銇疅琛岀祼鏋溿伅浠ヤ笅銇倛銇嗐伀澶夊寲銇椼伨銇欍

 0: cs:Connected ro:Primary/Secondary ds:Diskless/UpToDate C r-----

ds:銉曘偅銉笺儷銉夈伄鍊ゃ亴聽UpToDate/聽銇嬨倝聽Diskless/ 銇銈忋仯銇︺亜銈屻伆OK銇с仚銆

銉曘偋銈ゃ儷銈兗銉愩仚銈嬨亾銇ㄣ倰纰鸿獚

浠婂洖銇ō瀹氥仹銇乨rbd RA銇儮銉嬨偪銇10绉掗枔闅斻仹瀹熻銇曘倢銈嬨仧銈併佺磩10绉掍互鍐呫伀銉曘偋銈ゃ儷銈兗銉愩亴濮嬨伨銈嬨伅銇氥仹銇欍俢rm_mon銇〃绀恒亴澶夊寲銇椼仸cluster2銇屾柊銇熴仾銈€偗銉嗐偅銉栨銇仾銈嬨亾銇ㄣ倰纰鸿獚銇椼仸銇忋仩銇曘亜銆傘伨銇熴侀氱煡銉°兗銉亴root瀹涖伀閫佷俊銇曘倢銈嬨亾銇ㄣ倐銇旂⒑瑾嶃亸銇犮仌銇勩

鍏冦伀鎴汇仚

drbdadm attach 銈掑疅琛屻仚銈嬨仺銆併儑銈c偣銈亴鏁呴殰銇椼仧鐘舵厠銈掑厓銇埢銇涖伨銇欍default-resource-stickiness=INFINITY聽銇浉銇嶆彌銇堛仸鍚屾銇儑銈c偣銈倰鍒囥倞闆€仐銆併儠銈с偆銉偑銉笺儛銇椼仾銇勩亾銇ㄣ倐銇旂⒑瑾嶃亸銇犮仌銇勩

銇俱仺銈

DRBD銈掍娇銇嗐仺銆2鍙般伄銈点兗銉愩伄DRBD銉囥兗銈块牁鍩熴亴鍚屾檪鏁呴殰銇椼仾銇勯檺銈娿併儑銉笺偪銈掑畬鍏ㄣ伀鍠け銇欍倠銇撱仺銈掗伩銇戙倝銈屻伨銇欍傘仐銇嬨仐銇亴銈夈佺墖鏂广伄銉囥偅銈广偗銇犮亼銇屾晠闅溿仐銇熷牬鍚堛仹銈傘併仹銇嶃倠銇犮亼鏃┿亸銇濄伄銇撱仺銈掔煡銇c仸淇悊銇欍倠蹇呰銇屻亗銈娿伨銇欍

drbd.conf銇 on-io-error detach 銇 Pacemaker 銇 default-resource- stickiness=200 銈掔祫銇垮悎銈忋仜銈嬨仺銆佺鍍嶇郴銈点兗銉愩伄DRBD銉囥兗銈块牁鍩熴伄鏁呴殰銈扨acemaker銇屾鍑恒仹銇嶃倠銈堛亞銇仾銈娿伨銇欍傘仢銇椼仸銉曘偋銉笺儷銈兗銉愩亴璧枫亾銈娿併儜銉曘偐銉笺優銉炽偣浣庝笅銈掗伩銇戙倝銈屻伨銇欍

銇曘倝銇玀ailTo銉偨銉笺偣銈ㄣ兗銈搞偋銉炽儓銈掔祫銇胯炯銈撱仹銇娿亸銇撱仺銇倛銇c仸銆佺鐞嗚呫伅闅滃鐧虹敓銈掋儭銉笺儷銇х煡銈嬨亾銇ㄣ亴銇с亶銇俱仚銆

銇熴仩銇椼佸緟姗熺郴銈点兗銉愩伄DRBD銉囥兗銈块牁鍩熴亴鏁呴殰銇椼仸銈傘併儠銈с兗銉偑銉笺儛銇捣銇撱倞銇俱仜銈撱傘仐銇熴亴銇c仸銆佸疅闅涖伄銈儵銈广偪閬嬬敤銇亗銇熴仯銇︺伅銆丏RBD銇嫊浣滅姸鎱嬨伀闁€仚銈嬩綍銈夈亱銇閮ㄧ洠瑕栥仺绲勩伩鍚堛倧銇涖倠銇撱仺銈掋亰鍕с倎銇勩仧銇椼伨銇欍