您的位置:首页 > 其它

keepalived+haproxy配置故障

2015-03-20 16:04 274 查看
摘要: 配置keepalived出现脑裂

大家好。我在配置keepalived和haproxy的时候遇到脑裂的问题,还请大家帮助我分析一下,谢谢。我的环境信息如下:

一共两台虚拟机,是同个一共模板复制出来的(我怀疑问题出在这里)。

主机IP:192.168.1.136

备机IP:192.168.1.135

VIP:192.168.1.118

主机的keepalived的配置如下:

global_defs {

notification_email {

root

}

notification_email_from root

smtp_server 192.168.0.55

smtp_connect_timeout 30

router_id HAproxy

}

vrrp_script chk_haproxy {

script "/opt/check_haproxy.sh"

interval 2

weight 2

}

vrrp_instance HAproxy1 {

state MASTER #标示状态为MASTER 备份机为BACKUP

interface eth0

virtual_router_id 51

priority 100 #MASTER权重为100,BACKUP权重为90

advert_int 1

authentication {

auth_type PASS #主从服务器验证方式

auth_pass 1111

}

track_interface { # 监控的接口

eth0

eth1

}

virtual_ipaddress {

192.168.1.118/24 dev eth0

}

track_script {

chk_haproxy ### 执行监控的服务

}

}

备机的keepalived的配置如下:

global_defs {

notification_email {

root

}

notification_email_from root

smtp_server 192.168.0.55

smtp_connect_timeout 30

router_id HAproxy

}

vrrp_script chk_haproxy {

script "/opt/check_haproxy.sh"

interval 2

weight 2

}

vrrp_instance HAproxy1 {

state BACKUP #标示状态为MASTER 备份机为BACKUP

#interface eth0:1

#interface eth0.1

interface eth0

virtual_router_id 51

priority 90 #MASTER权重为100,BACKUP权重为90

advert_int 1

authentication {

auth_type PASS #主从服务器验证方式

auth_pass 1111

}

track_interface { # 监控的接口

eth0

eth1

}

virtual_ipaddress {

192.168.1.118/24 dev eth0

}

track_script {

chk_haproxy ### 执行监控的服务

}

}

主备机网络是通的。

主备机操作系统是CentOS6.1,keepalived的版本是Keepalived v1.2.15。

在我的测试环境中,我用上面的配置在主备机分别启动keepalived以后,发现备机先进入BACKUP在转换到MASTER模式。如下为日志

Keepalived[22262]: Starting Keepalived v1.2.15 (03/15,2015)

Keepalived[22263]: Starting VRRP child process, pid=22264

Keepalived_vrrp[22264]: Netlink reflector reports IP 192.168.1.135 added

Keepalived_vrrp[22264]: Netlink reflector reports IP 172.16.1.21 added

Keepalived_vrrp[22264]: Netlink reflector reports IP fe80::250:56ff:feb5:311e added

Keepalived_vrrp[22264]: Netlink reflector reports IP fe80::250:56ff:feb5:b8c4 added

Keepalived_vrrp[22264]: Registering Kernel netlink reflector

Keepalived_vrrp[22264]: Registering Kernel netlink command channel

Keepalived_vrrp[22264]: Registering gratuitous ARP shared channel

Keepalived_vrrp[22264]: Opening file '/etc/keepalived/keepalived.conf'.

Keepalived_vrrp[22264]: Configuration is using : 66715 Bytes

Keepalived_vrrp[22264]: Using LinkWatch kernel netlink reflector...

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Entering BACKUP STATE

Keepalived_vrrp[22264]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]

Keepalived_vrrp[22264]: VRRP_Script(chk_haproxy) succeeded

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Transition to MASTER STATE

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Entering MASTER STATE

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) setting protocol VIPs.

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Sending gratuitous ARPs on eth0 for 192.168.1.118

avahi-daemon[1783]: Registering new address record for 192.168.1.118 on eth0.IPv4.

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Sending gratuitous ARPs on eth0 for 192.168.1.118

系统咱们能有机会一起探讨一下如上的问题,如果我提供的信息不全,还请告诉我,我会立即补充。谢谢大家了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  keepalived