码迷,mamicode.com
首页 > 其他好文 > 详细

关于keepalive 问题处理

时间:2014-09-27 03:28:10      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:关于keepalive 问题处理

昨天新配置了Nginx Keepalived架构,今天上午来了VIP无法访问了,于是查看日志开始解决问题。

主服务器日志:
Sep 25 16:08:28 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 16:08:33 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:08:23 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:08:23 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:49 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:49 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:15:50 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1Sep 25 17:30:09 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new electionSep 25 17:30:51 modoor Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 1.1.1.1
从服务器日志:
Sep 25 15:58:19 wap Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Sep 25 15:58:19 wap Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 1.1.1.1
Sep 25 15:58:24 wap Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 1.1.1.1
Sep 25 16:08:25 wap Keepalived_vrrp: VRRP_Instance(VI_1) removing protocol VIPs.
Sep 25 16:11:32 wap Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
Sep 25 16:48:01 wap Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Sep 25 16:48:02 wap Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Sep 25 16:48:02 wap Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Sep 25 16:48:02 wap Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 1.1.1.1
Sep 25 16:48:05 wap Keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advert
Sep 25 16:48:05 wap Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
Sep 25 16:48:05 wap Keepalived_vrrp: VRRP_Instance(VI_1) removing protocol VIPs.
Sep 25 17:08:19 wap Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Sep 25 17:08:19 wap Keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advert
Sep 25 17:08:19 wap Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
Sep 25 17:08:23 wap Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Sep 25 17:08:24 wap Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Sep 25 17:08:24 wap Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Sep 25 17:08:24 wap Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 1.1.1.1
Sep 25 17:08:25 wap Keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advert
从日志分析:主备在反复的切换。于是查看自己的配置文件
我的配置文件是这样的:
global_defs {
   notification_email {
     yaoshenshen@test.com
   }
   notification_email_from root@localhost.localdomain
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_script chk_http_port {
                script "/opt/check_nginx.sh"
                interval 2
                weight 2
}
vrrp_instance VI_1 {
    state BACKUP        
    interface eth0
    virtual_router_id 50    
    mcast_src_ip 1.1.1.100
    priority 100                  
    advert_int 1
    nopreempt
    authentication {
        auth_type PASS
        auth_pass 1111
    }
track_script {
        chk_http_port ### 执行监控的服务
        }
    virtual_ipaddress {
       1.1.1.1
    }
}
检查配置文件没有问题。
然后怀疑问题出在/opt/check_nginx.sh 这个检测上面
/opt/check_nginx.sh 的内容是:
!/bin/bash
if [ $(ps -C nginx --no-header | wc -l) -eq 0 ]; then
     /etc/init.d/nginx  start
fi
sleep 2
if [ $(ps -C nginx --no-header | wc -l) -eq 0 ]; then
       /etc/init.d/keepalived stop
fi
仔细的读者会发现我这个脚本有问题,对!/bin/bash 前面少个#号。于是添加上,但是问题还是没有解决。 最后我再keepalive中取消了nginx的检测,keepalived正常了。


本文出自 “yaoshenshen” 博客,谢绝转载!

关于keepalive 问题处理

标签:关于keepalive 问题处理

原文地址:http://shenshen.blog.51cto.com/156530/1558652

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!