更新时间:2024-05-17 GMT+08:00

LVS主节点故障自动切备节点

测试目的

主LVS上的keep服务出现故障(如keepalived服务被关闭了),查看备lvs是否接管服务。

预置条件

LVS主备集群已配置正常。

测试方法

  1. 默认vip是在主节点上,执行以下命令,检查主节点网络配置。

    ip addr

    显示如下回显信息:

    [root@lvs-master ~]# ip addr
    eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 52:54:00:68:dc:b6 brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.157/27 brd 182.148.15.255 scope global eth0
        inet 192.168.0.27/32 scope global eth0
        inet6 fe80::5054:ff:fe68:dcb6/64 scope link
           valid_lft forever preferred_lft forever
  2. 执行以下命令,主节点停止keepalived服务。

    service keepalived stop

  3. vip漂移到备节点,主节点执行以下命令,原有的vip信息没有了。

    ip addr

    显示如下回显信息:

    root@lvs-master ~]# ip addr
    eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 52:54:00:68:dc:b6 brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.157/27 brd 182.148.15.255 scope global eth0
        inet 192.168.0.184/27 brd 182.148.15.255 scope global secondary eth0:0
        inet6 fe80::5054:ff:fe68:dcb6/64 scope link
           valid_lft forever preferred_lft forever

    备节点执行以下命令,查看网卡有vip信息。

    ip addr

    显示如下回显信息:

    [root@lvs-slave ~]# ip addr
    eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 52:54:00:68:dc:b6 brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.234/27 brd 182.148.15.255 scope global eth0
        inet 192.168.0.27/32 scope global eth0
        inet 192.168.0.184/27 brd 182.148.15.255 scope global secondary eth0:0
        inet6 fe80::5054:ff:fe68:dcb6/64 scope link
           valid_lft forever preferred_lft forever