在線上部署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
}
}