按照网上的教程搭建,两台服务器,主机ip:10.1.21.211,备机ip:10.1.21.212,虚ip:10.1.21.213。搭完后备用机一**启动keepalived就自动从BACKUP切换到MASTER(另一机并未关keepalived服务)**,正常主机没有down之前备机应该是backup状态才对啊,用ip a查看时发现备用机的IP也包含虚拟IP。
主机配置:
! Configuration File for keepalived
global_defs {
notification_email {
wangch_sk@163.com
}
notification_email_from 764382548@qq.com
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id node1
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.1.21.213
}
}
备机配置:
! Configuration File for keepalived
global_defs {
notification_email {
wangch_sk@163.com
}
notification_email_from 764382548@qq.com
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id node1
}
vrrp_instance VI_1 {
state BACKUP
interface eth1 #这里备机的网卡就是eth1
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.1.21.213
}
}
备机启动日志:
Apr 21 17:22:37 PEK1-OAHolidaySearch-02 Keepalived_healthcheckers[27471]: Using LinkWatch kernel netlink reflector...
Apr 21 17:22:37 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Entering BACKUP STATE
Apr 21 17:22:37 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Apr 21 17:22:41 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Transition to MASTER STATE
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Entering MASTER STATE
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) setting protocol VIPs.
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 10.1.21.213
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_healthcheckers[27471]: Netlink reflector reports IP 10.1.21.213 added
tcpdump vrrp结果:
18:09:44.834042 IP 10.1.21.211 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
18:09:45.331753 IP 10.1.21.212 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20
18:09:45.835228 IP 10.1.21.211 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
18:09:46.332927 IP 10.1.21.212 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20
这是什么情况? 求教各位大神解决方法或思路,谢谢