生命在于折腾~~~ 在SQL中摸爬滚打~~~ 微博 @iheycc
全部博文(4)
分类: Mysql/postgreSQL
2013-06-30 00:48:01
两台服务器都安装MySQL,搭建主主复制架构。具体搭建略。
Keepalived源码安装
安装依赖包
yum -y install popt-devel
安装Keepalived点击(此处)折叠或打开
mysqld和keepalived自启动
点击(此处)折叠或打开
库 |
IP |
服务VIP |
主 |
10.0.0.77 |
10.0.0.76 |
备 |
10.0.0.78 |
点击(此处)折叠或打开
从以下4个方面测试HA效果
keepalived down
mysqld down
网络故障
机器宕机
测试步骤和结果
keepalived down
步骤:kill master上的keepalived进程
结果:
>>slave的keepalived通知切换为master
mysqld down
步骤:kill master上的mysqld进程,或者提高master服务器的负载
结果:
>>master的keepalived通知因为mysqld down而停止keepalived
>>slave的keepalived通知切换为master
网络故障
步骤:master上ifconfig eth0 down,或者service network restart
结果:
>>master的keepalived通知变为fault状态
>>slave的keepalived通知切换为master
机器宕机
步骤:master机器重启
结果:
>>slave的keepalived通知切换为master
1,keepalived切换为master时,arping失败
有的环境测试,keepalived切换为master时,没有成功发送arping,导致VIP不同。所以给出了arping脚本
2,重启网卡,master变为fault状态,但没继续变为backup状态。
检查日志发现有错误信息
Keepalived_vrrp: Netlink: filter function error
Keepalived_healthcheckers: Netlink: filter function error
查找网络资料得知,keepalive不支持网络设备热插拔。ip link可以看出设备id变化了。
此时需要reload keepalived或者直接restart。
办法:网卡发生重启后,需检查keepalived是否正常
3,keepalived异常终止,VIP没有解除绑定,导致及时重启keepalived后,这个VIP也不能正常绑定和解除绑定
猜测原因是异常终止keepalived后,VIP没解除绑定,重启以后keepalived不识别未解除绑定的VIP。
办法:机器发生重启后需检查keepalived是否正常
4,ipvsadm使用yum安装,keepalived使用源码安装,keepalived不能启动healthchecker进程
keepalived安装时指定kernel目录:./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.18-308.1.1.el5-x86_64
5,关于virtual_router_id
virtual_router_id用来标识一对keepalived主从机的身份,不同keepalived对的这个id不能一样。取值范围1~255。如果不同组keepalived配置了同一个id,则会有如下报错:
Apr 7 14:31:11 localhost Keepalived_vrrp[22980]: ip address associated with VRID not present in received packet : 10.0.0.94 Apr 7 14:31:11 localhostKeepalived_vrrp[22980]: one or more VIP associated with VRID mismatch actual MASTER advert Apr 7 14:31:11 localhost Keepalived_vrrp[22980]: bogus VRRP packet received on eth0.181 !!! Apr 7 14:31:11 localhost Keepalived_vrrp[22980]: VRRP_Instance(mysql_ha) ignoring received advertisment... |
6,端口转发
virtual_server配置的端口,与real_server配置的端口必须一样?