在线上部署keepalived的时候遇到了问题总结下:


2台服务器

eth0为内网卡

eth1为外网卡

在主备切换的时候没有收到vrrp广播包

刚开始部署的时候copy的网上的配置文件,所以中招了

错误日志信息:/var/log/message

Oct  9 07:57:35 test4 Keepalived_vrrp[22495]: Sync instance needed on eth1 !!!
Oct  9 07:57:35 test4 Keepalived_vrrp[22495]: VRRP_Instance(VI_10) Dropping received VRRP packet...
Oct  9 07:57:37 test4 Keepalived_vrrp[22495]: advertissement interval mismatch mine=1000000 rcved=2
Oct  9 07:57:37 test4 Keepalived_vrrp[22495]: Sync instance needed on eth1 !!!
Oct  9 07:57:37 test4 Keepalived_vrrp[22495]: VRRP_Instance(VI_10) Dropping received VRRP packet...
Oct  9 07:57:39 test4 Keepalived_vrrp[22495]: advertissement interval mismatch mine=1000000 rcved=2
Oct  9 07:57:39 test4 Keepalived_vrrp[22495]: Sync instance needed on eth1 !!!
Oct  9 07:57:39 test4 Keepalived_vrrp[22495]: VRRP_Instance(VI_10) Dropping received VRRP packet...
Oct  9 07:57:41 test4 Keepalived_vrrp[22495]: advertissement interval mismatch mine=1000000 rcved=2
Oct  9 07:57:41 test4 Keepalived_vrrp[22495]: Sync instance needed on eth1 !!!
Oct  9 07:57:41 test4 Keepalived_vrrp[22495]: VRRP_Instance(VI_10) Dropping received VRRP packet...
Oct  9 07:57:43 test4 Keepalived_vrrp[22495]: advertissement interval mismatch mine=1000000 rcved=2
Oct  9 07:57:43 test4 Keepalived_vrrp[22495]: Sync instance needed on eth1 !!!
Oct  9 07:57:43 test4 Keepalived_vrrp[22495]: VRRP_Instance(VI_10) Dropping received VRRP packet..


解决方法:

vrrp_instance VI_10 {
    state BACKUP
    interface eth0   注意:eth0是内网网卡,这个选项是定义接受vrrp广播包的网卡,而不是有的博客说的虚拟ip绑定的网卡,这里被网上配置文件给坑了。
    virtual_router_id 111
    mcast_src_ip 10.28.163.89
    priority 100
    nopreempt

    authentication {
        auth_type PASS
        auth_pass HAmysql
    }

    track_script {
    check_mysqld
    }

    virtual_ipaddress {
    1.1.1.1/29 dev eth1 scope global 这里才是定义vip绑定的网卡为eth1
    }
}