Heartbeat与drbd结合高可以集群配置原理:
在heartbeat启动来之前,确保drbd服务正常,并且都是secondary/secondary状态
1.默认DRBD启动时两边都是secondary状态
[root@node110 ha.d]# cat /proc/drbd
version: 8.4.4 (api:1/proto:86-101)
GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a buildby root@node110, 2016-11-27 15:34:16
0: cs:Connectedro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
ns:0 nr:0 dw:0dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
heartbeat通过以下命令将secondary提升为主:
[root@node110 resource.d]# /etc/ha.d/resource.d/drbddiskdata start
[root@node110 resource.d]# cat /proc/drbd
version: 8.4.4 (api:1/proto:86-101)
GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a buildby root@node110, 2016-11-27 15:34:16
0: cs:Connectedro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:0 nr:0 dw:0dr:665 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
2.通过Filesystem自动挂载到相应的目录下:
[root@node110 ~]# /etc/ha.d/resource.d/Filesystem/dev/drbd0 /drbddata/ start
INFO: Running start for /dev/drbd0 on /drbddata
INFO: Starting filesystem check on /dev/drbd0
fsck from util-linux-ng 2.17.2
/dev/drbd0: clean, 12/610800 files, 76481/2441402blocks
INFO: Success
INFO: Success
[root@node110 ~]# cd /drbddata/
[root@node110 drbddata]# ls
lost+found rscpass
3.在网卡接口上配置IP地址:
[root@node110 ~]# /etc/ha.d/resource.d/IPaddr172.16.1.108/24/eth2 start
INFO: Adding inet address 172.16.1.108/24 withbroadcast address 172.16.1.255 to device eth2
INFO: Bringing device eth2 up
INFO: /usr/libexec/heartbeat/send_arp -i 200 -r 5 -p/var/run/resource-agents/send_arp-172.16.1.108 eth2 172.16.1.108 auto not_usednot_used
INFO: Success
INFO: Success
[root@node110 ~]# ARPING 172.16.1.108 from172.16.1.108 eth2
Sent 5 probes (5 broadcast(s))
Received 0 response(s)
[root@node110 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdiscnoqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet127.0.0.1/8 scope host lo
inet6 ::1/128scope host
valid_lftforever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu1500 qdisc pfifo_fast state UP qlen 1000
link/ether00:0c:29:44:24:b9 brd ff:ff:ff:ff:ff:ff
inet192.168.2.110/16 brd 192.168.255.255 scope global eth0
inet6fe80::20c:29ff:fe44:24b9/64 scope link
valid_lftforever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500qdisc pfifo_fast state UP qlen 1000
link/ether00:0c:29:44:24:c3 brd ff:ff:ff:ff:ff:ff
inet192.168.198.110/24 brd 192.168.198.255 scope global eth1
inet6fe80::20c:29ff:fe44:24c3/64 scope link
valid_lftforever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500qdisc pfifo_fast state UP qlen 1000
link/ether00:0c:29:44:24:cd brd ff:ff:ff:ff:ff:ff
inet172.16.1.110/24 brd 172.16.1.255 scope global eth2
inet172.16.1.108/24 brd 172.16.1.255 scope global secondary eth2
inet6fe80::20c:29ff:fe44:24cd/64 scope link
valid_lftforever preferred_lft forever
主节点配置
[root@node110 ~]# cat /etc/ha.d/haresources
#oldboy services
#node110 IPaddr::172.16.1.108/24/eth2
#node120 IPaddr::172.16.1.109/24/eth2
node110 drbddisk::dataFilesystem::/dev/drbd0::/drbddata::ext4 IPaddr::172.16.1.108/24/eth2 #只需要添加这条记录就可以了
#node120 drbddisk::dataFilesystem::/dev/drbd0::/drbddata::ext4 IPaddr::172.16.1.109/24/eth2 #如果添加了这条,将会有错误提示node120无法找到资源
[root@node110 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_node1-lv_root
50G 9.5G 38G 21% /
tmpfs 228M 0 228M 0% /dev/shm
/dev/sda1 477M 36M 416M 8% /boot
/dev/mapper/vg_node1-lv_home
47G 53M 45G 1% /home
/dev/drbd0 9.1G 21M 8.6G 1% /drbddata
[root@node110 ~]# cat /proc/drbd
version: 8.4.4 (api:1/proto:86-101)
GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a buildby root@node110, 2016-11-27 15:34:16
0: cs:Connectedro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:48 nr:16dw:64 dr:5867 al:2 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
备节点配置
[root@node120 /]# cat /etc/ha.d/haresources
#oldboy services
#node110 IPaddr::172.16.1.108/24/eth2
#node120 IPaddr::172.16.1.109/24/eth2
#node110 drbddisk::dataFilesystem::/dev/drbd0::/drbddata::ext4 IPaddr::172.16.1.108/24/eth4 #如果添加了这条,将会有错误提示node110无法找到资源
node120 drbddisk::dataFilesystem::/dev/drbd0::/drbddata::ext4 IPaddr::172.16.1.108/24/eth4 #只需要添加这条记录就可以了
[root@node120 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_node1-lv_root
50G 8.8G 38G 19% /
tmpfs 244M 0 244M 0% /dev/shm
/dev/sda1 477M 36M 416M 8% /boot
/dev/mapper/vg_node1-lv_home
47G 52M 45G 1% /home
[root@node120 /]# cat /proc/drbd
version: 8.4.4 (api:1/proto:86-101)
GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a buildby root@node120, 2016-11-27 15:43:45
0: cs:Connectedro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:16 nr:48dw:64 dr:2690 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0