天行流沙 2015-04-21 16:04 采纳率: 100%
浏览 3647
已结题

keepalived 备机启动自动从backup切换成master

按照网上的教程搭建,两台服务器,主机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

这是什么情况? 求教各位大神解决方法或思路,谢谢

  • 写回答

1条回答 默认 最新

  • 大犀牛88 2015-07-12 08:27
    关注

    关掉主备服务器的防火墙,备用服务器就可以进入BACKUP状态,而且启动关闭主服务器keepalived也可以实现主备切换。但正常情况下防火墙是不能关闭的,求高手最佳解决办法

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 dbLinq最新版linq sqlite
  • ¥20 对D盘进行分盘之前没有将visual studio2022卸载掉,现在该如何下载回来
  • ¥15 完成虚拟机环境配置,还有安装kettle
  • ¥15 2024年全国大学生数据分析大赛A题:直播带货与电商产品的大数据分析 问题5. 请设计一份优惠券的投放策略,需要考虑优惠券的数量、优惠券的金额、投放时间段和投放商品种类等因素。求具体的python代码
  • ¥15 有人会搭建生鲜配送自营+平台的管理系统吗
  • ¥15 用matlab写代码
  • ¥30 motoradmin系统的多对多配置
  • ¥15 求组态王串口自定义通信配置方法或代码?
  • ¥15 实验 :UML2.0 结构建模
  • ¥20 用vivado写数字逻辑实验报告撰写,FPGA实验