5.模拟心跳down机实验以及恢复
5.1 在目前主机上面创建crontab任务
[root@filer01 ~]# cat drbd.sh
#!/bin/bash
#env > /root/bbb
/sbin/ifconfig | grepeth1
if [ $? = 0 ]
then
echo " $(date +%F/%H:%M) : eth1 OK"
else
echo "$(date +%F/%H:%M): eth1 down ,stop service" >> /root/fail.txt
pkill corosync
fi
ping -c1192.168.11.223 &> /dev/null
if [ $? = 0 ]
then
echo " $(date +%F/%H:%M) : ping OK"
else
ping -c1 192.168.11.1 &> /dev/null
if [ $? = 0 ]
then
echo "$(date +%F/%H:%M) : ping 11.1OK 223 failed" >> /root/alter.txt
else
echo"$(date +%F/%H:%M): ping failed , stop service " >> /root/fail.txt
pkillcorosync
fi
fi
添加到crontab,时时检测问题。
[root@filer01 ~]#crontab -l
* * * * * sh/root/drbd.sh &
5.2 进行filer01 down机实验
而后主备的身份完成切换了,若是须要更换回到filer01,须要手动将filer02的网卡down掉按照上述过程从新切换回去便可。