DRBD:分布式复制块设备
- vim /etc/hosts
- 172.16.9.2 node2.test.com node2
- 172.16.9.3 node3.test.com node3
- ssh-keygen -t rsa -P ""
- ssh-copy-id -i /root/.ssh/id_rsa.pub dr2 root@node3
- date '12011340';ssh node3 'date 12011340'
- global {
- usage-count no;
- # minor-count dialog-refresh disable-ip-verification
- }
- ##########中间没做修改,为默认###############
- disk {
- on-io-error detach;
- #fencing resource-only;
- }
- net {
- cram-hmac-alg "sha1";
- shared-secret "mydrbdlab";
- }
- syncer {
- rate 1000M;
- }
- }
- resource mydrbd {
- on node2.test.com {
- device /dev/drbd0;
- disk /dev/sda5;
- address 172.16.9.2:7789;
- meta-disk internal;
- }
- on node3.test.com {
- device /dev/drbd0;
- disk /dev/sda5;
- address 172.16.9.3:7789;
- meta-disk internal;
- }
- }
- scp -r /etc/drbd.* node3:/etc/
- drbdadm create-md mydrbd
- service drbd start
- drbd-overview
- 0:mydrbd Connected Secondary/Secondary Inconsistent/Inconsistent C r-----
- [root@node2 ~]# drbd-overview
- 0:mydrbd SyncTarget Secondary/Secondary Inconsistent/UpToDate C r-----
- [=>..................] sync'ed: 13.9% (4120/4776)M
- drbdsetup /dev/drbd0 primary –o
- [root@node2 ~]# drbd-overview
- 0:mydrbd Connected Primary/Secondary UpToDate/UpToDate C r-----
- mke2fs -j -L DRBD /dev/drbd0
- mkdir /data/mydata -pv
- groupadd -r -g 333 mysql
- useradd -r -g 333 -u 333 mysql
- chown -R mysql:mysql /data/mydata
- mount /dev/drbd0 /data/mydata
- cd /usr/local
- ln -sv mysql-5.5.28-linux2.6-i686 mysql
- cd mysql
- chown -R root:mysql .
- scripts/mysql_install_db --user=myql --datadir=/data/mydata
- cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- cp support-files/my-large.cnf /data/mydata/my.cnf
- datadir=/data/mydata
- vim /etc/profile.d/mysql.sh
- export PATH=$PATH:/usr/local/mysql/bin
- source /etc/profile.d/mysql.sh #使之生效
- service mysqld stop
- chkconfig mysqld off
- cd /etc/corosync
- cp corosync.conf.example corosync.conf
- vim corosync.conf
- 添加如下内容
- service {
- ver: 0
- name: pacemaker
- }
- aisexec {
- user: root
- group: root
- }
- 同时将原来内容做下修改:
- secauth: on
- bindnetaddr: 172.16.0.0 #修改为主机所在网段
- to_syslog: no
- corosync-keygen
- scp -r corocync.conf authkey node3:/etc/corosync/
- mkdir /var/log/cluster
- ssh node3 'mkdir /var/log/cluster'
- Service corosync start
- Ssh node3 'service corosync start'
- crm
- ccrm(live)# configure
- crm(live)configure# property no-quorum-policy=ignore #取消法定票数的机制
- crm(live)configure# property stonith-enabled=false #禁用隔离设备
- crm(live)configure# primitive drbd ocf:linbit:drbd params drbd_resource="mydrbd" op start timeout=240 op stop timeout=240
- #根据自己需要定义资源的名字,类型等
- crm(live)configure# master ms_mydrbd drbd meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
- #master关键字定义主从资源,后面指定资源name,meta 指定额外参选数,master-max指定最多有几个master,
- #master-node-max指定一个节点最多运行几个master,clone-max指定有几个clone资源,
- #clone-node-max指定一个节点最多运行几个clone资源,notify指当出现故障时是否通知对方
- crm(live)configure# primitive myFS ocf:heartbeat:Filesystem params device="dev/drbd0" directory="/data/mydata" fstype="ext3" op start timeout=60 op stop timeout=60
- crm(live)configure# colocation myFS_on_ms_mydrbd inf: myFS ms_mydrbd:Master
- crm(live)configure# order myFS_after_ms_mydrbd mandatory: ms_mydrbd:promote myFS:start
- #将资源系统和drbd资源绑定在一个节点上,并定义其启动次序
- crm(live)configure# verify
- crm(live)configure# commit
- crm status
- ============
- Last updated: Mon Nov 12 16:45:35 2012
- Stack: openais
- Current DC: node2.test.com - partition with quorum
- Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
- 2 Nodes configured, 2 expected votes
- 2 Resources configured.
- ============
- Online: [ node3.test.com node2.test.com ]
- Master/Slave Set: ms_mydrbd [drbd]
- Masters: [ node3.test.com ]
- Slaves: [ node2.test.com ]
- myFS (ocf::heartbeat:Filesystem): Started node3.test.com
- crm(live)configure# primitive IP ocf:heartbeat:IPaddr params ip=172.16.66.1
- crm(live)configure# colocation IP_with_ms_mydrbd_master inf: IP ms_mydrbd:Master
- crm status
- ============
- Last updated: Mon Nov 12 16:54:25 2012
- Stack: openais
- Current DC: node2.test.com - partition with quorum
- Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
- 2 Nodes configured, 2 expected votes
- 4 Resources configured.
- ============
- Online: [ node3.test.com node2.test.com ]
- Master/Slave Set: ms_mydrbd [drbd]
- Masters: [ node3.test.com ]
- Slaves: [ node2.test.com ]
- myFS (ocf::heartbeat:Filesystem): Started node3.test.com
- MYSQL (lsb:mysqld): Started node3.test.com
- IP (ocf::heartbeat:IPaddr): Started node3.test.com
- crm node standby
- ##等待一会看资源是否转移
- crm(live)# status
- ============
- Last updated: Mon Nov 12 17:09:50 2012
- Stack: openais
- Current DC: node2.test.com - partition with quorum
- Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f
- 2 Nodes configured, 2 expected votes
- 4 Resources configured.
- ============
- Node node3.test.com: standby
- Online: [ node2.test.com ]
- Master/Slave Set: ms_mydrbd [drbd]
- Masters: [ node2.test.com ]
- Stopped: [ drbd:1 ]
- myFS (ocf::heartbeat:Filesystem): Started node2.test.com
- MYSQL (lsb:mysqld): Started node2.test.com
- IP (ocf::heartbeat:IPaddr): Started node2.test.com