[root@lb04 scripts]# cat ha_lv.sh #!/bin/bash while true do check_count=$(nmap 10.0.0.13|grep "Host is up"|wc -l) if [ ${check_count} -ne 1 ] then sh /server/scripts/lv_manager.sh start echo "切换服务器到16从服务器" arping -I eth0 -c 1 -U 10.0.0.13 sleep 1 get_ip=$(ip a|grep "10.0.0.13/24"|wc -l) [ ${get_ip} -eq 1 ] && echo "切换成功" fi sleep 3 done