How do simulate HA failover?

a. Network Down

1. Find the network interface device name for the ip address to be blocked via:

ifconfig

For example:

eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02
          inet addr:172.17.0.2  Bcast:172.17.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:737 (737.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:547263 errors:0 dropped:0 overruns:0 frame:0
          TX packets:547263 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:62402205 (62.4 MB)  TX bytes:62402205 (62.4 MB)

2. Run the following command to shutdown the nic (eth0 here)and bring it up after some time

sudo ifconfig eth0 down && sleep 180 && sudo ifconfig eth0 up

3. Run the HA testing script

b. Disk Down

1. Find the mount point of the disk to shut down via:

df -h

For example:

Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root          50G   12G   39G  23% /
devtmpfs                        252G     0  252G   0% /dev
tmpfs                           252G   21M  252G   1% /dev/shm
tmpfs                           252G  2.3G  250G   1% /run
tmpfs                           252G     0  252G   0% /sys/fs/cgroup
/dev/sda2                      1014M  308M  707M  31% /boot
/dev/sda1                       200M   12M  189M   6% /boot/efi
/dev/mapper/centos-home         3.7T  2.1T  1.6T  56% /home
192.168.11.9:/volume5/datapool   21T  8.4T   13T  40% /mnt/nfs_datapool
tmpfs                            51G     0   51G   0% /run/user/1001

2. Unmount the device from the mount point, e.g., /dev/sda1

sudo umount /boot/efi

3. Mount back the device via one of the following commands:

sudo mount /boot/efi
sudo mount /dev/sda1
sudo mount /dev/sda1 /boot/efi

c. System Down

Use one of the Linux system commands:

sudo halt
sudo reboot
sudo poweroff

or

sudo shutdown -H now
sudo shutdown -r now
sudo shutdown -h now

Make sure you have access to the machine after shut it down. Otherwise, always use reboot

1 Like