10. drbd主备切换测试,查看数据同步
在/drbd目录写入一个测试文件
dd if=/dev/zero of=drbdtest bs=4k count=10240
在原来的primary上卸载drbd,并设置为secondary
umount /drbd
drbdadm secondary r0
把原来的secondary设置为primary,并挂载drbd
drbdadm primary r0
mount /dev/drbd1 /drbd
查看刚才的文件是否存在,说明同步成功
[root@test2 drbd]# ll -h /drbd/drbdtest
-rw-r--r--. 1 root root 40M Nov 7 14:55 /drbd/drbdtest
11. 由于CentOS6.3的iso并没有heartbeat的rpm包,所以采用互联网上的资源下载安装epel,可以直接yum install heartbeat
rpm -ivUh epel-release-6-5.noarch.rpm
vi /etc/yum.repos.d/epel.repo #把第6行改成enabled=0
使用yum安装heartbeat
yum --enablerepo=epel install heartbeat
12. 修改heartbeat配置文件(以下步骤需要在2台node上执行)
复制配置文件,资源文件,认证密钥文件
cp /usr/share/doc/heartbeat-3.0.4/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.4/haresources /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.4/authkeys /etc/ha.d/
vi /etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility local0
keepalive 1 #定义心跳频率1s
deadtime 10 #如果其他节点10S内没有回应,则确认其死亡
warntime 5 #确认一个节点连接不上5S之后将警告信息写入日志
initdead 60 #在其他节点死掉之后,系统启动前需要等待的时间,一般为deadtime的两倍
udpport 694
ucast eth0 192.168.169.110 #对端的IP,在备机上改为192.168.169.100
auto_failback off
node cc-system-manager1
node cc-system-manage
chmod 600 /etc/ha.d/authkeys
vi /etc/ha.d/authkeys
auth 1
1 Crc
2
vi /etc/ha.d/haresources
test1 IPaddr::192.168.159.250/24/eth0 drbddisk::r0 Filesystem::/dev/drbd1::/drbd::ext3 nginx
资源文件说明:
test1– the hosname that will be the primary node
drbddisk::r0 – activate the r0 resource disk (make sure r0 corresponds to whatever your resource is named)
Filesystem::/dev/drbd1::/drbd::ext3 – mount /dev/drbd1 on /drbd as ext3 filesystem
nginx–the service we’re going to watch over and take care of, in this case nginx(which wasn’t really what I was configuring, but it’s the easiest to show as an example)