1.什么是脑裂
keepalived高可用的服务器之间出现ping不通,但服务器还在运行的状况,然后互相争抢资源。
2.裂脑发生的原因
a)高可用服务器之间心跳线链路故障,导致无法正常通信。
b)心跳线坏了(包括断了,老化)。
c)网卡即相关驱动坏了,IP配置及冲突问题(网卡直连)
d)心跳线间连接的设备故障(网卡及交换机)
e)高可用服务器对上开启了iptables防火墙阻挡了心跳信息传输。
f)高可用服务器对上心跳网卡地址等信息配置不正确,导致发送心跳失败。
g)其他服务器配置不当等原因,如心跳方式不同,心跳广播冲突,软件BUG
解决裂脑的常见方案
a)同时使用串行电缆和以太网电缆连接,同时用两条心跳线路,这样一条线路坏了,另一个还是好的,依然能传送心跳消息。
b)当检测到裂脑时强行关闭一个心跳节点(这个功能需特殊设备支持,如fence,stonith)。相当于备节点接收不到心跳信息,发送关机命令通过单独的线路关闭主节点电源。
c)做好对裂脑的监控报警(如邮件及手机短信等),在问题发生时人为的第一时间介入仲裁,降低损失。
4.编写脚本监控脑裂
4.1测试两台高可用之间能否通
[root@lb01 ~]# ping -c 2 -W 3 10.0.0.11
PING 10.0.0.11 (10.0.0.11) 56(84) bytes of data.
64 bytes from 10.0.0.11: icmp_seq=1 ttl=64 time=0.460 ms
64 bytes from 10.0.0.11: icmp_seq=2 ttl=64 time=0.374 ms
--- 10.0.0.11 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.374/0.417/0.460/0.043 ms
[root@lb02 ~]# ping -c 2 -W 3 10.0.0.10
PING 10.0.0.10 (10.0.0.10) 56(84) bytes of data.
64 bytes from 10.0.0.10: icmp_seq=1 ttl=64 time=0.484 ms
64 bytes from 10.0.0.10: icmp_seq=2 ttl=64 time=0.567 ms
--- 10.0.0.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.484/0.525/0.567/0.047 ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
4.2查看VIP
[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 -l
0
1
2
3
4
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
The server suffered a brain fracture
The server suffered a brain fracture
The server suffered a brain fracture
1
2
3
4
5
6
7
8
9
10
11
12
13
14
4.4脚本内容
[root@client-01 ~]# cat brain.sh
while true
do
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" -ne 0 -a "$B_num01" -ne 0 ];then
exit 1
fi
M_num02=`ssh $Master ip add|grep $Vip|wc -l`
B_num02=`ssh $Backup ip add|grep $Vip|wc -l`
if [ "$M_num02" -ne 0 -a "$B_num02" -ne 0 ];then
echo "The server suffered a brain fracture"
else
echo "Server normal"
fi
done
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞2
添加新评论0 条评论