1)
同一套keepalived集群中virtual_router_id 要保持一致
/var/log/messages日志keepalived启动正常日志:
Nov 18 22:42:07 db01 Keepalived_vrrp[26691]: Opening file '/etc/keepalived/keepalived.conf'. Nov 18 22:42:07 db01 Keepalived_vrrp[26691]: VRRP_Instance(VI_2) removing protocol VIPs. Nov 18 22:42:07 db01 Keepalived_vrrp[26691]: Using LinkWatch kernel netlink reflector... Nov 18 22:42:07 db01 Keepalived_vrrp[26691]: VRRP sockpool: [ifindex(6), proto(112), unicast(0), fd(10,11)] Nov 18 22:42:08 db01 Keepalived_vrrp[26691]: VRRP_Instance(VI_2) Transition to MASTER STATE Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: VRRP_Instance(VI_2) Entering MASTER STATE Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: VRRP_Instance(VI_2) setting protocol VIPs. Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: VRRP_Instance(VI_2) Sending/queueing gratuitous ARPs on bond0 for 192.168.10.147 Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:09 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:14 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:14 db01 Keepalived_vrrp[26691]: VRRP_Instance(VI_2) Sending/queueing gratuitous ARPs on bond0 for 192.168.10.147 Nov 18 22:42:14 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:14 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:14 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 Nov 18 22:42:14 db01 Keepalived_vrrp[26691]: Sending gratuitous ARP on bond0 for 192.168.123.147 (END)
2)
在同一网段内非同一套keepalived集群中virtual_router_id 值不能相同
案例:
配置文件内容:
cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { [email protected] [email protected] [email protected] } notification_email_from [email protected] smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id Server_01 } vrrp_instance VI_1 { state MASTER interface bond0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.10.3/24 } }
/var/log/messages日志keepalived启动报错
Mar 14 01:29:21 test Keepalived_vrrp[819]: VRRP_Instance(mysql-ha) ignoring received advertisment... Mar 14 01:29:22 test Keepalived_vrrp[819]: ip address associated with VRID not present in received packet : 192.168.32.53 Mar 14 01:29:22 test Keepalived_vrrp[819]: one or more VIP associated with VRID mismatch actual MASTER advert Mar 14 01:29:22 test Keepalived_vrrp[819]: bogus VRRP packet received on bond0 !!! Mar 14 01:29:22 test Keepalived_vrrp[819]: VRRP_Instance(mysql-ha) ignoring received advertisment... Mar 14 01:29:23 test Keepalived_vrrp[819]: ip address associated with VRID not present in received packet : 192.168.32.53 Mar 14 01:29:23 test Keepalived_vrrp[819]: one or more VIP associated with VRID mismatch actual MASTER advert Mar 14 01:29:23 test Keepalived_vrrp[819]: bogus VRRP packet received on bond0 !!!
解决方法:
修改virtual_router_id的值,从51改为88,因为之前在同一网段还有别的机器安装过keepalived,并设置了virtual_router_id=51,改成不同的值后重启keepalived后问题得到解决.
3)
在同一个网段内的,若为不同的应用做高可用,不同应用使用不同的VIP,那么vrrp_instance的名字(这里是VI_1)、virtual_router_id在不同的高可用实例必须设置不同的值区分开
案例:
配置文件内容:
cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id Server_01
}
vrrp_instance VI_1 {
state MASTER
interface bond0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.100.3/24 ##做为数据库的高可用
192.168.100.4/24 ##做为tomcat的高可用
}
}
/var/log/messages日志keepalived启动报错:
Aug 11 11:28:36 localhostKeepalived_vrrp[16958]: (VI_1): received an invalid ip number count 1, expected2! Aug 11 11:28:36 localhostKeepalived_vrrp[16958]: bogus VRRP packet received on eth1 !!! Aug 11 11:28:36 localhostKeepalived_vrrp[16958]: VRRP_Instance(VI_1) Dropping received VRRP packet…
解决办法:针对不通应用的高可用,配置不同的vrrp_instance和virtual_router_id
详情配置如下:
cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { [email protected] [email protected] [email protected] } notification_email_from [email protected] smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id Server_01 } vrrp_instance VI_1 { state MASTER interface bond0 virtual_router_id 88 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.3/24 ##做为数据库的高可用 } } vrrp_instance VI_2 { state MASTER interface bond0 virtual_router_id 99 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.4/24 ##做为tomcat的高可用 } }