当主机主机再次启动时,不会传回Keepalived虚拟IP

时间:2016-06-21 08:41:26

标签: networking high-availability failover virtual-ip-address floating-ip

我正在使用2个流浪汉Centos7实例安装keepalived for virtual IP failover但有问题(我在生产时遇到同样的问题)。

基本上,我有两个运行keepalived的实例。以下是这两台服务器的配置keepalived.conf:

Server1的配置:

global_defs {
   notification_email {
      ABC@gmail.com
   }
   notification_email_from server1.dev.vagrant.net
   smtp_server localhost
   smtp_connect_timeout 30
}

  vrrp_instance VI_enp0s8 {
      state MASTER
      interface enp0s8
      virtual_router_id 51
      priority 100
      advert_int 1
      authentication {
          auth_type PASS
          auth_pass 1111
      }
      virtual_ipaddress {
                    192.168.65.110
                    192.168.65.111

      }
  }

Server2的配置:

global_defs {
   notification_email {
      ABC@gmail.com
   }
   notification_email_from server2.dev.vagrant.net
   smtp_server localhost
   smtp_connect_timeout 30
}

  vrrp_instance VI_enp0s8 {
      state BACKUP
      interface enp0s8
      virtual_router_id 51
      priority 99
      advert_int 1
      authentication {
          auth_type PASS
          auth_pass 1111
      }
      virtual_ipaddress {
                    192.168.65.110
                    192.168.65.111

      }
  }

基本上,如果我停止使用keepalived:sudo service keepalived stop on server1;然后将虚拟ipaddresses成功传输到server2。当我使用“sudo service keepalived start”开始使用“sudo service keepalived start”重新启动keepalived时,会将ip地址转回。当我在server1上执行“sudo reboot”时,一切都正常工作。

但是,如果我关闭然后使用以下命令重新启动server1:sudo shutdown -h now(或vagrant halt server1)然后将server1弄乱,则虚拟IP将不会分配给任一服务器。 (ip addr show enp0s8)。

下面是/ var / log / messages的日志。在我看来,由于某种原因,虚拟IP已被添加,但随后被删除。

Jun 21 08:19:50 oasis4 Keepalived_vrrp[724]: VRRP_Instance(VI_enp0s8) Entering MASTER STATE
Jun 21 08:19:50 oasis4 Keepalived_vrrp[724]: VRRP_Instance(VI_enp0s8) setting protocol VIPs.
Jun 21 08:19:50 oasis4 Keepalived_healthcheckers[723]: Netlink reflector reports IP 192.168.65.110 added
Jun 21 08:19:50 oasis4 Keepalived_healthcheckers[723]: Netlink reflector reports IP 192.168.65.111 added
Jun 21 08:19:50 oasis4 Keepalived_vrrp[724]: VRRP_Instance(VI_enp0s8) Sending gratuitous ARPs on enp0s8 for 192.168.65.110
Jun 21 08:19:50 oasis4 Keepalived_vrrp[724]: VRRP_Instance(VI_enp0s8) Sending gratuitous ARPs on enp0s8 for 192.168.65.111
Jun 21 08:19:52 oasis4 Keepalived_healthcheckers[723]: Netlink reflector reports IP 192.168.65.104 removed
Jun 21 08:19:52 oasis4 Keepalived_vrrp[724]: Netlink reflector reports IP 192.168.65.104 removed
Jun 21 08:19:52 oasis4 Keepalived_healthcheckers[723]: Netlink reflector reports IP 192.168.65.110 removed
Jun 21 08:19:52 oasis4 Keepalived_vrrp[724]: Netlink reflector reports IP 192.168.65.110 removed
Jun 21 08:19:52 oasis4 Keepalived_healthcheckers[723]: Netlink reflector reports IP 192.168.65.111 removed
Jun 21 08:19:52 oasis4 Keepalived_vrrp[724]: Netlink reflector reports IP 192.168.65.111 removed
Jun 21 08:19:52 oasis4 kernel: e1000: enp0s8 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
Jun 21 08:19:52 oasis4 kernel: IPv6: ADDRCONF(NETDEV_UP): enp0s8: link is not ready
Jun 21 08:19:52 oasis4 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): enp0s8: link becomes ready
Jun 21 08:19:54 oasis4 Keepalived_healthcheckers[723]: Netlink reflector reports IP 192.168.65.104 added
Jun 21 08:19:54 oasis4 Keepalived_vrrp[724]: Netlink reflector reports IP 192.168.65.104 added
Jun 21 08:19:55 oasis4 Keepalived_vrrp[724]: VRRP_Instance(VI_enp0s8) Sending gratuitous ARPs on enp0s8 for 192.168.65.110
Jun 21 08:19:55 oasis4 Keepalived_vrrp[724]: VRRP_Instance(VI_enp0s8) Sending gratuitous ARPs on enp0s8 for 192.168.65.111
Jun 21 08:19:55 oasis4 systemd: Starting Session 2 of user vagrant.
Jun 21 08:19:55 oasis4 systemd: Started Session 2 of user vagrant.
Jun 21 08:19:55 oasis4 systemd-logind: New session 2 of user vagrant.
Jun 21 08:19:56 oasis4 systemd-logind: Removed session 1.
Jun 21 08:20:00 oasis4 systemd: Starting Session 3 of user vagrant.
Jun 21 08:20:00 oasis4 systemd: Started Session 3 of user vagrant.
Jun 21 08:20:00 oasis4 systemd-logind: New session 3 of user vagrant.
Jun 21 08:20:01 oasis4 systemd: Starting user-0.slice.
Jun 21 08:20:01 oasis4 systemd: Created slice user-0.slice.
Jun 21 08:20:01 oasis4 systemd: Starting Session 4 of user root.

如果我登录到server1然后手动重启keepalived,那么事情就会开始正常工作。

任何人都可以告诉我配置是否有问题?

另外,有几次我无法使用sudo service keepalived stop正常停止服务;发生这种情况时,虚拟IP不会分配给任何一台服务器。

感谢。

1 个答案:

答案 0 :(得分:1)

根据日志,keepalived已在网络接口enp0s8启动并准备就绪之前启动。如果您希望keepalived跟踪接口,则应在vrrp_instance

中添加类似的内容
track_interface {
    enp0s8
}