阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Keepalived VIP自动切换

215次阅读
没有评论

共计 1802 个字符,预计需要花费 5 分钟才能阅读完成。

Keepalived VIP 切换的两种情况:

1.keepalived 进程被停止。

2.keepalived 中 track_script 检测失败。

haproxy 检测:

vrrp_script chk_haproxy {
  script “killall -0 haproxy”    # cheaper than pidof
  interval 2                # check every 2 seconds
  weight -2
}

切换相关日志:tail -f /var/log/messages

Keepalived_vrrp[32408]: VRRP_Script(chk_haproxy) failed
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Received higher prio advert
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Entering BACKUP STATE
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) removing protocol VIPs.
Keepalived_vrrp[32408]: VRRP_Script(chk_haproxy) succeeded
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) forcing a new MASTER election
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) forcing a new MASTER election
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Transition to MASTER STATE
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Entering MASTER STATE
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) setting protocol VIPs.
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 10.1.1.56
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 10.1.1.56

切换失败的情况:

keepalived 进程被停止时 VIP 可以正常切换,keepalived 进程运行状态下,haproxy 相关服务停止后,VIP 未如期进行切换。

分析:

停止 haproxy 服务,手动执行 killall -0 haproxy && echo “success” || echo “fail”,返回结果是 success。

停止 haproxy 服务后,ps aux |grep haproxy 发现还有一个正常启动的 haproxy,killall -9 haproxy 后发现 tail -f /var/log/messages 出现 VIP 正常切换的日志。

Linux 下 HAProxy+Keepalived 双机高可用方案  http://www.linuxidc.com/Linux/2016-02/128566.htm

Haproxy+Keepalived 搭建 Weblogic 高可用负载均衡集群 http://www.linuxidc.com/Linux/2013-09/89732.htm

Keepalived+HAProxy 配置高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/56748.htm

CentOS 6.3 下 Haproxy+Keepalived+Apache 配置笔记 http://www.linuxidc.com/Linux/2013-06/85598.htm

Haproxy + KeepAlived 实现 WEB 群集 on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm

Haproxy+Keepalived 构建高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/55880.htm

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-03/129015.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计1802字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中