Drdb,简介
resource web { on node1.nyist.com { device /dev/drbd0; disk /dev/sd5; address 172.16.20,31:7789; meta-disk internal; } on node2.nyist.com { device /dev/drbd0;---设备编号 disk /dev/sd5;---磁盘位置 address 172.16.20,32:7789;---共享出去的挂载点 meta-disk internal; } }
[root@node2 drbd.d]# drbdadm create-md web Writing meta data... initializing activity log NOT initializing bitmap--------可以忽略这个错误 lk_bdev_save(/var/lib/drbd/drbd-minor-0.lkbd) failed: No such file or directory New drbd meta data block successfully created. lk_bdev_save(/var/lib/drbd/drbd-minor-0.lkbd) failed: No such file or directory [root@node1 drbd.d]# cat /proc/drbd version: 8.4.3 (api:1/proto:86-101) GIT-hash: 89a294209144b68adb3ee85a73221f964d3ee515 build by gardner@, 2013-11-29 12:28:00 0: cs:Connected ro:Secondary/Secondary ds:Diskless/Diskless C r----- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
[root@node1 drbd.d]# drbdadm primary --force web [root@node1 drbd.d]# cat /proc/drbd version: 8.4.3 (api:1/proto:86-101) GIT-hash: 89a294209144b68adb3ee85a73221f964d3ee515 build by gardner@, 2013-11-29 12:28:00 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:55156 nr:0 dw:0 dr:55316 al:0 bm:4 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 [root@node1 drbd.d]# mke2fs -t ext4 /dev/drbd0
[root@node1 ~]# mkdir /mydata [root@node1 ~]# mount /dev/drbd0 /mydata [root@node1 ~]# cp /etc/issue /mydata/ [root@node1 ~]# umount /mydata [root@node1 ~]# drbdadm secondary web [root@node1 ~]# cat /proc/drbd version: 8.4.3 (api:1/proto:86-101) GIT-hash: 89a294209144b68adb3ee85a73221f964d3ee515 build by gardner@, 2013-11-29 12:28:00 0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r----- ns:61405 nr:0 dw:6249 dr:55793 al:2 bm:4 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 [root@node1 ~]#
[root@node2 drbd.d]# drbdadm primary web [root@node2 drbd.d]# cat /proc/drbd version: 8.4.3 (api:1/proto:86-101) GIT-hash: 89a294209144b68adb3ee85a73221f964d3ee515 build by gardner@, 2013-11-29 12:28:00 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:0 nr:61405 dw:61405 dr:160 al:0 bm:4 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 [root@node2 drbd.d]# mkdir /mydata [root@node2 drbd.d]# mount /dev/drbd0 /mydata/ [root@node2 drbd.d]# ls /mydata/ issue lost+found [root@node2 drbd.d]#
root@xuqimin ~]# ansible all -m yum -a "name=pacemaker state=present" [root@xuqimin ~]# ansible all -m yum -a "name=corosync state=present" [root@node2 ~]# yum install crmsh-1.2.6-4.el6.x86_64.rpm pssh-2.3.1-2.el6.x86_64.rpm -y
[root@node2 ~]# umount /dev/drbd0 [root@node2 ~]# drbdadm secondary web [root@node2 ~]# service drbd stop Stopping all DRBD resources: . [root@node2 ~]# chkconfig drbd off
[root@node1 ~]# crm status Last updated: Tue Apr 22 23:56:27 2014 Last change: Tue Apr 22 23:54:31 2014 via crmd on node1.nyist.com Stack: classic openais (with plugin) Current DC: node1.nyist.com - partition with quorum Version: 1.1.10-14.el6-368c726 2 Nodes configured, 2 expected votes----两个节点已经到位 0 Resources configured Online: [ node1.nyist.com node2.nyist.com ]
crm(live)configure# property no-quorum-policy=ignore crm(live)configure# property stonith-enabled=false crm(live)configure# rsc_defaults resource-stickiness=100 crm(live)configure# show node node1.nyist.com node node2.nyist.com property $id="cib-bootstrap-options" \ dc-version="1.1.10-14.el6-368c726" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \ stonith-enabled="false" \ default-resource-stickiness="100" \ no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \ resource-stickiness="100"
crm(live)configure# primitive webdrbd ocf:linbit:drbd params drbd_resource=web op monitor role=Master interval=50s timeout=30s op monitor role=Slave interval=60s timeout=30s crm(live)configure# master MS_webdrbd webdrbd meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" scrm(live)configure# show node node1.nyist.com node node2.nyist.com primitive webdrbd ocf:linbit:drbd \ params drbd_resource="web" \ op monitor role="Master" interval="50s" timeout="30s" \ op monitor role="Slave" interval="60s" timeout="30s" ms MS_webdrbd webdrbd \ meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" target-role="Started" property $id="cib-bootstrap-options" \ dc-version="1.1.10-14.el6-368c726" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \ stonith-enabled="false" \ default-resource-stickiness="100" \ no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \ resource-stickiness="100" crm(live)resource# start webdrbd crm(live)# status 2 Nodes configured, 2 expected votes 2 Resources configured Online: [ node1.nyist.com node2.nyist.com ] Master/Slave Set: MS_webdrbd [webdrbd] Masters: [ node2.nyist.com ] Slaves: [ node1.nyist.com ]
crm(live)configure# primitive WebFS ocf:heartbeat:Filesystem params device="/dev/drbd0" directory="/www" fstype="ext3" 定义排列约束 crm(live)configure# order WebFS_after_webdrbd inf: WebFS MS_webdrbd crm(live)configure# show node node1.nyist.com node node2.nyist.com \ attributes standby="off" primitive WebFS ocf:heartbeat:Filesystem \ params device="/dev/drbd0" directory="/www" fstype="ext3" primitive webdrbd ocf:linbit:drbd \ params drbd_resource="web" \ op monitor role="Master" interval="50s" timeout="30s" \ op monitor role="Slave" interval="60s" timeout="30s" ms MS_webdrbd webdrbd \ meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" target-role="Started" order WebFS_after_webdrbd inf: WebFS MS_webdrbd