Updated on 2024-05-17 GMT+08:00

LVS Automatically Switching to the Standby Node When the Primary Node Is Faulty

Objectives

When the keepalived service on the primary LVS node is faulty (for example, the keepalived service is disabled), the standby LVS node takes over services.

Prerequisites

The LVS primary and standby cluster have been correctly configured.

Test Methods

  1. The VIP is on the primary node by default. Run the following command to check the network configuration of the primary node:

    ip addr

    The following information is displayed:

    [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. Run the following command to stop the keepalived service on the primary node.

    service keepalived stop

  3. After the VIP is assigned to the standby node, run the following command on the primary node to verify that the VIP information does not exist.

    ip addr

    The following information is displayed:

    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

    Run the following command on the standby node to check whether the VIP information exists:

    ip addr

    The following information is displayed:

    [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