1,由于heartbeat 不能綁定IP赏淌,經(jīng)過一星期的定位,終于找到解決方案啄清,領(lǐng)導(dǎo)不用劈我了六水,哈哈哈哈!
2辣卒,以下是使用keeopalived 解決方案
腳本 1 : check_nfs.sh
?#!/bin/sh
###檢查nfs可用性:進程和是否能夠掛載
/sbin/service nfs status &>/dev/null
if [ $? -ne 0 ];then
###如果服務(wù)狀態(tài)不正常掷贾,先嘗試重啟服務(wù)
/sbin/service nfs restart
/sbin/service nfs status &>/dev/null
if [ $? -ne 0 ];then
###若重啟nfs服務(wù)后,仍不正常
###卸載drbd設(shè)備
umount /dev/drbd0
###將drbd主降級為備
drbdadm secondary r0
#關(guān)閉keepalived
/sbin/service keepalived stop
fi
fi
腳本 2 : notify_backup.sh
#!/bin/bash
time=`date "+%F? %H:%M:%S"`
echo -e "$time? ? ------notify_backup------\n" >> /etc/keepalived/logs/notify_backup.log
/sbin/service nfs stop &>> /etc/keepalived/logs/notify_backup.log
/bin/umount /dev/drbd0 &>> /etc/keepalived/logs/notify_backup.log
/sbin/drbdadm secondary r0 &>> /etc/keepalived/logs/notify_backup.log
echo -e "\n" >> /etc/keepalived/logs/notify_backup.log
腳本 3: notify_master.sh
#!/bin/bash
time=`date "+%F? %H:%M:%S"`
echo -e "$time? ? ------notify_master------\n" >> /etc/keepalived/logs/notify_master.log
/sbin/drbdadm primary r0 &>> /etc/keepalived/logs/notify_master.log
/bin/mount /dev/drbd0 /web &>> /etc/keepalived/logs/notify_master.log
/sbin/service nfs restart &>> /etc/keepalived/logs/notify_master.log
echo -e "\n" >> /etc/keepalived/logs/notify_master.log
腳本 4 :notify_stop.sh
#!/bin/bash
time=`date "+%F? %H:%M:%S"`
echo -e "$time? ------notify_stop------\n" >> /etc/keepalived/logs/notify_stop.log
/sbin/service nfs stop &>> /etc/keepalived/logs/notify_stop.log
/bin/umount /web &>> /etc/keepalived/logs/notify_stop.log
/sbin/drbdadm secondary r0 &>> /etc/keepalived/logs/notify_stop.log
echo -e "\n" >> /etc/keepalived/logs/notify_stop.log
3, 參考鏈接
blog.csdn.net/nimasike/article/details/52463806? ?// keepalived 不搶占VIP
blog.csdn.net/kai404/article/details/52860222? ? ? // keepalived+nfs+drbd
www.heminjie.com/system/linux/3313.html? ? ? ? ? // heartbeat+nfs+drbd
note.youdao.com/share/? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 腳本下載地址
studys.blog.51cto.com/9736817/1656222? ? ? ? ? ? ?//keepalived 介紹