[root@lb01 ~]# ip add|grep 10.0.0.100
inet 10.0.0.100/24 scope global secondary eth0
[root@lb02 ~]# ip add|grep 10.0.0.100|wc -l0
4.3在管理端,执行脚本(管理端可以免秘钥操作两台高可用服务器)
[root@client-01 ~]# bash brain.sh
Server normal
Server normal
Server normal
Server normal
===================到这里打开防火墙
[root@lb01 ~]# /etc/init.d/iptables start
iptables: Applying firewall rules: [ OK ]
[root@lb02 ~]# /etc/init.d/iptables start
iptables: Applying firewall rules: [ OK ]
====================
The server suffered a brain fracture
The server suffered a brain fracture
The server suffered a brain fracture
4.4脚本内容
[root@client-01 ~]# cat brain.sh #!/bin/bashwhiletruedo
Master=10.0.0.10
Backup=10.0.0.11
Vip=10.0.0.100
M_num01=`/bin/ping -c 2 -W 3$Master >/dev/null 2>&1 ; echo $?`
B_num01=`/bin/ping -c 2 -W 3$Backup >/dev/null 2>&1 ; echo $?`
if [ "$M_num01"-ne0-a"$B_num01"-ne0 ];thenexit1fi
M_num02=`ssh $Master ip add|grep $Vip|wc -l`
B_num02=`ssh $Backup ip add|grep $Vip|wc -l`
if [ "$M_num02"-ne0-a"$B_num02"-ne0 ];thenecho"The server suffered a brain fracture"elseecho"Server normal"fidone