1
2
| Rhel 6.5
selinux & iptablesdisabled
|
这里和之前配置一样:
1
2
3
4
5
6
7
8
9
10
11
12
| [iyunv@server2~]# cat /etc/ha.d/ha.cf | grep -v '^#'
debugfile/var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive2
deadtime30
warntime10
initdead70
mcasteth1 225.0.0.122 694 1 0
auto_failbackon
node server2.example.com
node server1.example.com
|
- Drbd的配置,也和之前的一样:生产环境最好调节速度为带宽的30%
注意drbd配置好是HA正确切换的前提
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [iyunv@server2~]# cat /etc/drbd.d/drbd0.res
resourcedata0 {
meta-diskinternal;
device/dev/drbd1;
syncer {
verify-algsha1;
}
onserver2.example.com {
disk/dev/sdc1;
address192.168.88.122:7789;
}
onserver1.example.com {
disk/dev/sdc1;
address192.168.88.121:7789;
} }
|
服务端:
1
2
3
4
5
| yum grouplist nfs*;
[iyunv@server1 /]# cat /etc/exports 也可以直接exportfs之前命令触发
/data192.168.88.0/24(rw,sync)
[iyunv@server1/]# ll -d /data/
drwxrwxrwx 2 root root 3072 Jul 20 12:51 /data/
|
客户端: 1
2
3
| yum install rpcbind -y
yum install nfs-uti
/etc/init.d/rpcbind start
|
测试:mount -t nfs 192.168.88.122:/data /datatest/ (.122 IP并非VIP。只是测试NFS) 1
2
| [iyunv@server1 ha.d]# cat haresources | grep -v '^#'
server2.example.com IPaddr::192.168.88.200/24/eth0drbddisk::data0 Filesystem::/dev/drbd1::/data::ext4 nfs_restart
|
上面nfs_restart必须注意。 nfs_restart存在原因: 因为在一个节点down的时候,HA会释放资源,其中会umount nfs分享目录。但是客户端一直在用着。所以HA怎么也不会卸载掉,在日志ha-debug中一直can’t umount、the device is busy最后实在不行,只能把自己重启,释放资源。 Heartbeat开始资源是顺序开启的,释放资源是逆序释放。 nfs_restart 只是之卸载之前重启下服务。至于为什么重启服务就好了,感觉很奇怪。 1
2
3
| [root@server1ha.d]# cat resource.d/nfs_restart
#!/bin/bash
/etc/init.d/nfs restart
|
- 测试。Down机,downheartbeat,都OK。
但是在客户端写操作的时候会有1-2分钟的延迟。至于解决办法,有人说在客户端重新mount下。但我测试下,依然不可取。Google下,有人推荐用共享存储还没试。
|