高可用检测脚本failover.sh

#!/bin/sh

VIP="10.0.0.1"

DEV="eth0"


healthcheck(){

ping -c 1 -w 1 $VIP >/dev/null

return $?

}

ip_takeover(){

MAC=`ip link show $DEV|egrep -o '([0-9a-f]{2}:){5}[0-9a-f]{2}'|head -n 1|tr -d :`

ip addr  add $VIP/24 dev $DEV

send_arp $VIP $MAC 255.255.255.255 ffffffffffff

}

while healthcheck;do

echo "health ok!"

sleep 1

done

echo "fail over"

ip_takeover

上一篇:延迟加载算法微服务的模型


下一篇:less13 颜色值函数