云平台keepalive主备都有vip
初始配置如下,测试发现VIP不会漂移,仔细查看发现两台机器上都有VIP。
#master
/etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id wiilead
}
vrrp_instance VI_1 {
state MASTER
interface eth0 #网卡名
virtual_router_id 51
priority 150 #权重
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.185.220.5 #vip
}
}
#backup
/etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id wiilead
}
vrrp_instance VI_1 {
state BACKUP
interface eth0 #网卡名
virtual_router_id 51
priority 100 #权重
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.185.220.5 #vip
}
}
听说:云平台上联交换机禁用了arp的广播限制,造成keepalive无法通过广播通信,两台服务器同时存在了vip。tcpdump -i eth0 vrrp -n
检查网卡的消息发送。
配置本机IP,与对端IP后
,VIP正常出现漂移。
#master
! Configuration File for keepalived
global_defs {
router_id wiilead
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 100
unicast_src_ip 10.3.0.58 #本机IP
unicast_peer {
10.3.0.56 #对端IP
}
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.3.0.57
}
}
#backup
! Configuration File for keepalived
global_defs {
router_id wiilead
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
unicast_src_ip 10.3.0.56 #本机IP
unicast_peer {
10.3.0.58 #对端IP
}
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.3.0.57
}
}