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

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也可以实现主备切换。但正常情况下防火墙是不能关闭的,求高手最佳解决办法

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

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。