Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, May 22, 2018

vSphere: Process Lock Issue

Recently, we faced an issue in vSphere 6.5, after cancelling an OVF export mid-process. In this blog we will go through the troubleshooting process in detail and the resolution. 


The Issue


One of our customers exported a Virtual Machine from vCenter and cancelled the process before completion. Then the VM could not be powered ON. The error received was:

 Error Stack:   
   An error was received from the ESX host while powering on VM TEST-VM.  
  Failed to start the virtual machine.  
  Module 'Disk' power on failed.   
  Cannot open the disk '/vmfs/volumes/5753f99f-d235ca6c-a280-d89d6779a96c/TEST-VM/TEST-VM_1.vmdk' or one of the snapshot disks it depends on.   
  Failed to lock the file  
  File system specific implementation of LookupAndOpen[file] failed  
  File system specific implementation of LookupAndOpen[file] failed  
  File system specific implementation of LookupAndOpen[file] failed  
  File system specific implementation of OpenFile[file] failed  

On checking the vmkernel log file we find the below issue.

 [root@test:/var/log] tail -f vmkernel.log   
 num 1 gblnum 0 gblgen 0 gblbrk 0] alloc owner 3833856  
 2019-11-12T11:38:08.515Z cpu18:72666)DLX: 4312: vol 'RAID5_DATASTORE2', lock at 94683136: [Req mode 1] Checking liveness:  
 2019-11-12T11:38:08.515Z cpu18:72666)[type 10c00001 offset 3763970 v 55, hb offset 3686970  
 gen 745, mode 2, owner 00000000-00000000-0000-000000000000 mtime 6167 num 1 gblnum 0 gblgen 0 gblbrk 0]  

On running the following command we can see that there is a Lock of type 10c00001 and mode 0. However the owner is 00000000-00000000-0000-000000000000.

 [root@test:/vmfs/volumes/5753f99f-d235ca6c-a280-d89d6779a96c/TEST-VM] vmkfstools -D /vmfs/volumes/5753f99f-d235ca6c-a280-d89d6779a96c/TEST-VM/TEST-VM.vmx   

 Lock [type 10c00001 offset 60387328 v 456, hb offset 3686970 gen 3, mode 0, owner 00000000-00000000-0000-000000000000 mtime 12601 num 0 gblnum 0 gblgen 0 gblbrk 0]   
 Addr <4, 121, 70>, gen 142, links 1, type reg, flags 0, uid 0, gid 0, mode 100755 len 3486, nb 1 tbz 0, cow 0, newSinceEpoch 1, zla 2, bs 8192  

The different mode types described on VMware site are as following:

  • mode 0 = no lock
  • mode 1 = is an exclusive lock (vmx file of a powered on VM, the currently used disk (flat ir delta), *vswp, etc)
  • mode 2 = is a read-only lock (e.g. on the ..-flat.vmdk of a running VM with snapshots)
  • mode 3 = is a multi-writer lock. (e.g. used for MSCS clusters disks or FT VMs)

We can determine the owner (host) where the process is locked by running the following command with the offset value from previous output (offset 3686970).

 [root@test: /vmfs/volumes/5753f99f-d235ca6c-a280-d89d6779a96c/TEST-VM] hexdump -C /vmfs/volumes/5753f99f-d235ca6c-a280-d89d6779a96c/.vh.sf -n 512 -s 3686970  

 003ba000 00 40 5d 7e 00 00 00 00 00 00 00 00 89 00 00 00 |……;………|  
 003ba010 00 00 00 00 c9 dd 7f a1 5c 01 00 00 89 e8 ba 55 |….._../…….|  
 003ba020 e1 ff 30 43 c1 dd 7f 8e 3d 3a 21 1a a4 a6 8a 99 |..m....S...….|  
 003ba030 e0 00 00 00 9d 04 00 00 00 00 00 00 00 00 00 00 |…......……..|  
 003ba040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |…………….|  

By checking the MAC address of the hosts, we can verify the host where the process is locked. In this case it was the same host where the VM was located. The MAC address of one the host's NIC included (7f 8e 3d 3a), as indicated in the above output.


Troubleshooting Steps


First, we removed the VM (TEST-VM) from inventory. Then registered the VM to the same host. The problem was still persistent.

Second, removed the VM from inventory and created a new VM with the same virtual drives from the problematic VM (TEST-VM). While trying to power ON the new VM the problem still persisted.

Third, we restarted the ESXi host daemon 'hostd' and vCenter Agent 'vpxa' services on the host to no avail.

 /etc/init.d/hostd restart  
 /etc/init.d/vpxa restart  

Fourth, we restarted all the management services on the host. However, the problem was not resolved.

 services.sh restart  

Fifth, we rebooted the host and tried to power ON the VM. The issue was still there.


The Resolution


Since the OVF export process was run from vCenter, there was still a process that was locking the VM in vCenter and we were unable to power on the VM. We had already rebooted the host, so we could conclude that the host was not locking the VM.

We rebooted the vCenter and finally we could power ON the VM without any issues.



References



Friday, April 13, 2018

Linux: Multipath Configuration In Linux

For this post I have setup an HPE DL380 Gen 10 server with two single port QLogic FC HBAs (Host Bus Adapter). This server is connected to 3PAR Storage through FC cables via SAN Switch. 

Loading QLogic Driver Modules


The QLogic HBA is shown in the OS (CentOS 7) as shown below.

 [root@localhost ~]# lspci -nn | grep -i fibre  
 12:00.0 Fibre Channel [0c04]: QLogic Corp. Device [1077:2261] (rev 01)  
 13:00.0 Fibre Channel [0c04]: QLogic Corp. Device [1077:2261] (rev 01)  

To load the QLogic kernel module we need to run the following command. The "-v" option is for verbose output.

 [root@localhost ~]# modprobe -v qla2xxx   

We can verify that the qla2xxx module is loaded as shown below.

 [root@localhost ~]# modinfo qla2xxx | grep version  
 version:    8.07.00.28.07.0-k1  
 srcversion:   3B54D31D167574AF88D5492  
 vermagic:    3.10.0-123.el7.x86_64 SMP mod_unload modversions   

The module is also listed on lsmod output.

 [root@localhost ~]# lsmod | grep qla  
 qla2xxx        652312 8   
 scsi_transport_fc   59960 1 qla2xxx  

The two hosts host0 and host3, displayed in the first output below, are the two QLogic FC adapters with the WWNN (World Wide Node Names) displayed in the second output.

 [root@localhost ~]# ls /sys/class/fc_host/  
 host0 host3  

 [root@localhost ~]# cat /sys/class/fc_host/host*/node_name  
 0x51402ec012cf8387  
 0x51402ec012cf8371  

Scanning FC Hosts

After the driver modules were loaded, the ports on SAN Switch connected to the server were all green and the server FC Host WWNN and WWPN were shown in the SAN Switch. Then zoning was configured and a 10 GB LUN was exported to the server. I have not included the commands of zoning and LUN creation done on SAN Switch and 3PAR storage respectively.

On the server we need to scan the FC Hosts for the LUNs to be present. The "- - -" are wild cards in the format "Channel Target LUN". These wild cards are used to rescan everything.

 [root@localhost ~]# echo "1" > /sys/class/fc_host/host0/issue_lip
 [root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
 [root@localhost ~]# echo "1" > /sys/class/fc_host/host3/issue_lip
 [root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host3/scan

After rescanning the hosts the LUN is present and the output of lsblk shows four devices /dev/sdc, /dev/sdd, /dev/sde and /dev/sdf. These four devices represent the four FC paths.

 [root@localhost ~]# lsblk  
 NAME      MAJ:MIN RM SIZE RO TYPE MOUNTPOINT  
 sda        8:0  1 1.1T 0 disk   
 ├─sda1      8:1  1 200M 0 part /boot/efi  
 ├─sda2      8:2  1 500M 0 part /boot  
 └─sda3      8:3  1 1.1T 0 part   
  ├─centos-swap 253:0  0  4G 0 lvm  [SWAP]  
  ├─centos-root 253:1  0  50G 0 lvm  /  
  └─centos-home 253:2  0  1T 0 lvm  /home  
 sdc        8:32  0  10G 0 disk      
 sdd        8:48  0  10G 0 disk     
 sde        8:64  0  10G 0 disk     
 sdf        8:80  0  10G 0 disk     

Configuring Multipath


To enable multipath with user friendly names for the LUNs, we run the following command.

 [root@localhost ~]# mpathconf --enable --user_friendly_names y  

Then we add the option path_selector "round-robin 0" in the /etc/multipath.conf file. The default algorithm for path selection will be round-robin.

 defaults {  
     user_friendly_names yes  
     find_multipaths yes  
     path_selector "round-robin 0"  
 }  

To configure multipath we run the following command.

 [root@localhost ~]# multipath  

Now we list the multipath devices. Our LUN is present as mpatha as we have specified user_friendly_names to be used for LUNs and has sdc, sdd, sde and sdf as slaves.

 [root@localhost ~]# multipath -ll  
 mpatha (360002ac000000000000002180001cf1f) dm-3 3PARdata,VV         
 size=10G features='0' hwhandler='0' wp=rw  
 `-+- policy='round-robin 0' prio=1 status=active  
  |- 0:0:0:0 sdc 8:32 active ready running  
  |- 0:0:1:0 sdd 8:48 active ready running  
  |- 3:0:0:0 sde 8:64 active ready running  
  `- 3:0:1:0 sdf 8:80 active ready running  

Reloading and restarting the multipathd service needs to be done for the changes to be reflected. The enable option starts the service permanently on reboot.

 [root@localhost ~]# systemctl reload multipathd.service   
 [root@localhost ~]# systemctl restart multipathd.service
 [root@localhost ~]# systemctl enable multipathd.service  

Now the four devices are listed as part of mpatha.

 [root@localhost ~]# lsblk  
 NAME      MAJ:MIN RM SIZE RO TYPE MOUNTPOINT  
 sda        8:0  1 1.1T 0 disk   
 ├─sda1      8:1  1 200M 0 part /boot/efi  
 ├─sda2      8:2  1 500M 0 part /boot  
 └─sda3      8:3  1 1.1T 0 part   
  ├─centos-swap 253:0  0  4G 0 lvm  [SWAP]  
  ├─centos-root 253:1  0  50G 0 lvm  /  
  └─centos-home 253:2  0  1T 0 lvm  /home  
 sdc        8:32  0  10G 0 disk   
 └─mpatha    253:3  0  10G 0 mpath   
 sdd        8:48  0  10G 0 disk   
 └─mpatha    253:3  0  10G 0 mpath   
 sde        8:64  0  10G 0 disk   
 └─mpatha    253:3  0  10G 0 mpath   
 sdf        8:80  0  10G 0 disk   
 └─mpatha    253:3  0  10G 0 mpath   

Checking the device details of /dev/mapper/mpatha using fdisk.

 [root@localhost ~]# fdisk -l /dev/mapper/mpatha  
 Disk /dev/mapper/mpatha: 10.7 GB, 10737418240 bytes, 20971520 sectors  
 Units = sectors of 1 * 512 = 512 bytes  
 Sector size (logical/physical): 512 bytes / 512 bytes  
 I/O size (minimum/optimal): 16384 bytes / 16777216 bytes  

Other details such as multipath device name and and the slaves of the device can be viewed as given below.

 [root@localhost ~]# cat /sys/block/dm-3/dm/name   
 mpatha  
 [root@localhost ~]# ls /sys/block/dm-3/slaves/  
 sdc sdd sde sdf  

Monday, April 2, 2018

Linux: Creating Startup Service Using SYSTEMD UNIT

Sometimes we might have a requirement to create a custom script or service that needs to be run at startup. In this post we will be testing the creation of a custom service that changes the MAC Address of the wireless and ethernet Network Interface Card on boot. This process is achieved by creating a Systemd Unit file. This test was performed on Fedora Linux version 31.

Creating the Systemd Unit File

To create a Systemd Unit File we will create the following file.

 vim /etc/systemd/system/macchange@.service  

The contents of the above file are as follows.

 [Unit]  
 Description=macchanger on %I  
 Wants=network-pre.target  
 Before=network-pre.target  
 After=sys-subsystem-net-devices-%i.device  

 [Service]  
 ExecStart=/usr/bin/macchanger -r %I  
 Type=oneshot  

 [Install]  
 WantedBy=multi-user.target  

Starting Services

We will now enable the services for both the wireless and as well as ethernet NIC. Enabling the services will start the services on boot. 

 # systemctl enable macchange@wlp2s0.service  

 # systemctl enable macchange@enp1s0.service  

We will test the service by rebooting the device.

Testing the Setup

Before rebooting, we check the MAC Address of the interfaces enp1s0 (c8:d3:ff:fd:f2:a4) and wlp2s0 (94:53:30:78:5f:d1).

 $ ifconfig  
 enp1s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500  
     ether c8:d3:ff:fd:f2:a4 txqueuelen 1000 (Ethernet)  
     RX packets 0 bytes 0 (0.0 B)  
     RX errors 0 dropped 0 overruns 0 frame 0  
     TX packets 0 bytes 0 (0.0 B)  
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  

 wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500  
     inet 192.168.20.4 netmask 255.255.255.0 broadcast 192.168.200.255  
     inet6 fe80::f016:771c:2a61:f3d3 prefixlen 64 scopeid 0x20<link>  
     ether 94:53:30:78:5f:d1 txqueuelen 1000 (Ethernet)  
     RX packets 80646 bytes 82143411 (78.3 MiB)  
     RX errors 0 dropped 0 overruns 0 frame 0  
     TX packets 40453 bytes 6154019 (5.8 MiB)  
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  

After rebooting, we can see that the MAC Addresses have been changed to enp1s0 (96:af:17:f0:9e:1f) and wlp2s0 (aa:5f:09:97:64:06).


 $ ifconfig  
 enp1s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500  
     ether 96:af:17:f0:9e:1f txqueuelen 1000 (Ethernet)  
     RX packets 0 bytes 0 (0.0 B)  
     RX errors 0 dropped 0 overruns 0 frame 0  
     TX packets 0 bytes 0 (0.0 B)  
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  


 wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500  
     inet 192.168.20.4 netmask 255.255.255.0 broadcast 192.168.20.255  
     inet6 fe80::f016:771c:2a61:f3d3 prefixlen 64 scopeid 0x20<link>  
     ether aa:5f:09:97:64:06 txqueuelen 1000 (Ethernet)  
     RX packets 80646 bytes 82143411 (78.3 MiB)  
     RX errors 0 dropped 0 overruns 0 frame 0  
     TX packets 40453 bytes 6154019 (5.8 MiB)  
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  

So we have successfully configured Systemd service to randomly change the MAC Address of WLAN and LAN NIC on boot by utilizing the macchanger tool.

References


Creating a Linux service with systemd - Benjamin Morel - Medium
Use systemd to Start a Linux Service at Boot | Linode
[SOLVED] Could not change MAC. & Setup Macchanger auto spoofing/randomization in Kali
10.6. Creating and Modifying systemd Unit Files Red Hat Enterprise Linux 7 | Red Hat Customer Portal

Thursday, March 22, 2018

Linux: Tape Drive Configuration in Linux

In this blog, we are going to test writing data to a tape library. The tape library is HPE MSL 2024 with 24 tape slots and two tape drives. The tapes are LTO Ultrium 7 with 15 TB capacity. The tape library must be connected to a physical server, in this case we have connected the tape library to the physical server via Fibre Channel. We have setup Cent OS 7 in the physical server.

The tape library can be managed via Web GUI shown below.



We can check if the tape devices are present in the server as SCSI devices by running the following commands in the Cent OS server:

 [root@backup ~]# lsscsi  
 [0:0:0:0]  tape  HP    Ultrium 7-SCSI  HB81 /dev/st1   
 [1:0:0:0]  storage HP    P420i      8.00 -      
 [1:1:0:0]  disk  HP    LOGICAL VOLUME  8.00 /dev/sda   
 [4:0:0:0]  tape  HP    Ultrium 7-SCSI  HB81 /dev/st0   
 [4:0:0:1]  mediumx HP    MSL G3 Series  7.00 /dev/sch0  

 [root@backup ~]# cat /proc/scsi/scsi  
 Attached devices:  
 Host: scsi1 Channel: 00 Id: 00 Lun: 00  
  Vendor: HP    Model: P420i      Rev: 8.00  
  Type:  RAID               ANSI SCSI revision: 05  
 Host: scsi1 Channel: 01 Id: 00 Lun: 00  
  Vendor: HP    Model: LOGICAL VOLUME  Rev: 8.00  
  Type:  Direct-Access          ANSI SCSI revision: 05  
 Host: scsi4 Channel: 00 Id: 00 Lun: 00  
  Vendor: HP    Model: Ultrium 7-SCSI  Rev: HB81  
  Type:  Sequential-Access        ANSI SCSI revision: 06  
 Host: scsi4 Channel: 00 Id: 00 Lun: 01  
  Vendor: HP    Model: MSL G3 Series  Rev: 7.00  
  Type:  Medium Changer          ANSI SCSI revision: 05  
 Host: scsi0 Channel: 00 Id: 00 Lun: 00  
  Vendor: HP    Model: Ultrium 7-SCSI  Rev: HB81  
  Type:  Sequential-Access        ANSI SCSI revision: 06  

We can see in the above output that three tape devices are present in the server:

  1. The first device is a  "Sequential-Access" tape drive, present as /dev/st0.
Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: HP Model: Ultrium 7-SCSI Rev: HB81
Type: Sequential-Access ANSI SCSI revision: 06

      2. The second device is a "Sequential-Access" tape drive, present as /dev/st1.

Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: HP Model: Ultrium 7-SCSI Rev: HB81
Type: Sequential-Access ANSI SCSI revision: 06

     3. The third device is the "Medium Changer" or the tape library hosting the tapes and the tape drives.

Host: scsi4 Channel: 00 Id: 00 Lun: 01
Vendor: HP Model: MSL G3 Series Rev: 7.00
Type: Medium Changer ANSI SCSI revision: 05

  
It is important to note that Linux presents the tape drives with two types of device files:

  1. /dev/st0 and /dev/st1.
  2. /dev/nst0 and /dev/nst1.
The "n" in the second file type stands for non-rewinding tape. If we use /dev/st0 and write data to the tape, the tape will auto rewind to the beginning of the tape and the data will be overwritten with new data while writing data the second time.

However, if we use /dev/nst0 and write data to the tape, the tape will not auto rewind to the beginning of the tape and new data can be written sequentially after the previous data. 

For management of tape drive, we will run the "mt" commands and "tar" commands to write data to the tapes.

For checking the status of the two tape drives the following commands are run:

 [root@backup ~]# mt -f /dev/nst0 status  
 SCSI 2 tape drive:  
 File number=0, block number=0, partition=0.  
 Tape block size 0 bytes. Density code 0x5c (no translation).  
 Soft error count since last status=0  
 General status bits on (41010000):  
  BOT ONLINE IM_REP_EN  

 [root@backup ~]# mt -f /dev/nst1 status  
 SCSI 2 tape drive:  
 File number=-1, block number=-1, partition=0.  
 Tape block size 0 bytes. Density code 0x0 (default).  
 Soft error count since last status=0  
 General status bits on (50000):  
  DR_OPEN IM_REP_EN  

The first tape drive /dev/nst0 status, indicates that the tape is loaded from it's slot to the first tape drive. The tape is ready for data to be written and the general status indicates BOT ONLINE IM_REP_EN. BOT means Beginning Of Tape.

The second tape drive /dev/nst1 status, indicates the tape drive is empty with the general status DR_OPEN IM_REP_EN.

For this test we have run the commands as root user, however, we should create a different user with privileges for production systems.

I have created empty files by running "touch test{1..5}" shown below.

 [root@backup ~]# ls  
 anaconda-ks.cfg devices scsi tape test1 test2 test3 test4 test5  

Now, we write these test files to the first tape drive using tar.

 [root@backup ~]# tar -cvzf /dev/nst0 test1 test2 test3 test4 test5  
 test1  
 test2  
 test3  
 test4  
 test5  

After writing data, the tape needs to be rewind to check and verify that data has been written.

 [root@backup ~]# mt -f /dev/nst0 rewind  

Then, we check the status of the tape drive to verify that the tape is at the beginning.

 [root@backup ~]# mt -f /dev/nst0 status  
 SCSI 2 tape drive:  
 File number=0, block number=0, partition=0.  
 Tape block size 0 bytes. Density code 0x5c (no translation).  
 Soft error count since last status=0  
 General status bits on (41010000):  
  BOT ONLINE IM_REP_EN  

Now, we verify the test data by running tar.

 [root@backup ~]# tar -tzf /dev/st0  
 test1  
 test2  
 test3  
 test4  
 test5  

After checking the data by running above command, the tape will wind to the end of the data. We again rewind the tape:

 [root@backup ~]# mt -f /dev/nst0 rewind  

 [root@backup ~]# mt -f /dev/nst0 status  
 SCSI 2 tape drive:  
 File number=0, block number=0, partition=0.  
 Tape block size 0 bytes. Density code 0x5c (no translation).  
 Soft error count since last status=0  
 General status bits on (41010000):  
  BOT ONLINE IM_REP_EN  

Then, we go to the end of the data:

 [root@backup ~]# mt -f /dev/nst0 eod  

And check the status of the tape drive to verify the tape is at the end of data denoted by general status EOD ONLINE IM_REP_EN.

 [root@backup ~]# mt -f /dev/nst0 status  
 SCSI 2 tape drive:  
 File number=1, block number=-1, partition=0.  
 Tape block size 0 bytes. Density code 0x5c (no translation).  
 Soft error count since last status=0  
 General status bits on (9010000):  
  EOD ONLINE IM_REP_EN  

For a final test we erase the contents of the tape. Since we are at the end of data, we need to rewind again.

 [root@backup ~]# mt -f /dev/nst0 rewind  

Now, we erase the contents of the tape in the first tape drive.

 [root@backup ~]# mt -f /dev/nst0 erase  

So, we have tested by writing data to tape drives from Linux server successfully. These are basic operations required to manually write data to a single tape drive or a tape library. However, in practice, it is preferred to use a backup software solution where a backup configuration is done according to the company's backup policy for automatic backup and to prevent potential human error.







Saturday, March 10, 2018

Linux: Configure VPN using NMCLI

Recently I was trying to connect to a PPTP VPN from my home workstation, which has fedora 30 installed and I wasn't able to. So I researched online about it and figured how to create a VPN connection using 'Network Manager' tool nmcli.

Below I have demonstrated the method of creating the connection.

Create Connection

 [spameggs@foobar ~]$ sudo nmcli connection add connection.id VPN_2 connection.type vpn connection.interface-name wlp2s0 connection.permissions spameggs vpn.service-type pptp vpn.data gateway=199.202.117.191   
 [spameggs@foobar ~]$ sudo nmcli connection modify VPN_2 vpn.user-name numb vpn.secrets password=damisk76  

We can check the connection details from the related file VPN_2.nmconnection created in the below location.

 [spameggs@foobar system-connections]$ pwd  
 /etc/NetworkManager/system-connections  

 [spameggs@foobar system-connections]$ sudo cat VPN_2.nmconnection   
 [sudo] password for spameggs:   
 [connection]  
 id=VPN_2  
 uuid=1342c044-108a-447c-8712-de988346fccb  
 type=vpn  
 interface-name=wlp2s0  
 permissions=user:spameggs:;  
   
 [vpn]  
 gateway=199.202.117.191  
 service-type=org.freedesktop.NetworkManager.pptp  
 user-name=numb  
 [vpn-secrets]  
 password=damisk76  
 [ipv4]  
 dns-search=  
 method=auto  
 [ipv6]  
 addr-gen-mode=stable-privacy  
 dns-search=  
 method=auto  

Test Connection


I could not connect the VPN and I see the following logs from journalctl.

 Started the VPN service, PID 6152  
 Saw the service appear; activating connection  
 VPN connection: (ConnectInteractive) reply received  
 VPN plugin: state changed: starting (3)  
 VPN plugin: failed: connect-failed (1)  
 VPN plugin: state changed: stopping (5)  
 VPN service disappeared  

Load Modules


I did further research and found that we need to load some modules. There are two methods for this process. For temporary use we can run the following command from a privileged user.

 [root@drone ~]# for module in nf_nat_pptp nf_conntrack_pptp
 > do  
 > modprobe $module;  
 > done  

Or we can load these modules on boot permanently by adding the above module names in the file /etc/modules-load.d/netfilter.conf as follows.

 [spameggs@foobar ~]$ sudo cat /etc/modules-load.d/netfilter.conf  
 nf_nat_pptp  
 nf_conntrack_pptp  

We need to reboot for the changes to occur.

Configure Firewall Rules


There is no need to make any changes in Selinux. However, we have to add few rules in the firewall to allow PPTP connections.

 [spameggs@foobar ~]$ sudo firewall-cmd --permanent --add-port=1723/tcp   
 [spameggs@foobar ~]$ sudo firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT  
 [spameggs@foobar ~]$ sudo firewall-cmd --permanent --direct --add-rule ipv6 filter INPUT 0 -p gre -j ACCEPT  
 [spameggs@foobar ~]$ sudo firewall-cmd --permanent --add-masquerade  
 [spameggs@foobar ~]$ sudo firewall-cmd --reload  

Reconnect Successfully


We can see below that the connection is finally established successfully.

 [spameggs@foobar ~]$ nmcli connection up VPN_2   
 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)  

Verify Connection


We can verify by checking the output of ifconfig. A new ppp0 interface has been automatically created with the IP address 192.168.101.149.

 ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1400  
     inet 192.168.101.149 netmask 255.255.255.255 destination 192.168.101.150  
     ppp txqueuelen 3 (Point-to-Point Protocol)  
     RX packets 1271 bytes 1398779 (1.3 MiB)  
     RX errors 0 dropped 0 overruns 0 frame 0  
     TX packets 1213 bytes 127555 (124.5 KiB)  
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  

The command ip addr also shows the ppp0 interface.

 [foobar@drone system-connections]$ ip addr  
 12: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1400 qdisc fq_codel state UNKNOWN group default qlen 3  
   link/ppp   
   inet 192.168.101.149 peer 192.168.101.151/32 scope global ppp0  
     valid_lft forever preferred_lft forever  

We can check the routes for the VPN traffic by running ip route and route commands.

 [spameggs@foobar ~]$ ip route  
 default dev ppp0 proto static scope link metric 50   
 default via 192.168.100.1 dev wlp2s0 proto dhcp metric 600   
 192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.29 metric 600   
 192.168.100.1 dev wlp2s0 proto static scope link metric 600   
 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown   
 192.168.101.149 dev ppp0 proto kernel scope link src 192.168.101.148 metric 50   
 199.202.117.191 via 192.168.100.1 dev wlp2s0 src 192.168.100.29   
 199.202.117.191 via 192.168.100.1 dev wlp2s0 proto static metric 600   

 [spameggs@foobar ~]$ route  
 Kernel IP routing table  
 Destination   Gateway     Genmask     Flags Metric Ref  Use Iface  
 default     0.0.0.0     0.0.0.0     U   50   0    0 ppp0  
 default     _gateway    0.0.0.0     UG  600  0    0 wlp2s0  
 192.168.100.0   0.0.0.0     255.255.255.0  U   600  0    0 wlp2s0  
 _gateway    0.0.0.0     255.255.255.255 UH  600  0    0 wlp2s0  
 192.168.122.0  0.0.0.0     255.255.255.0  U   0   0    0 virbr0  
 192.168.101.149 0.0.0.0     255.255.255.255 UH  50   0    0 ppp0  
 199.202.117.191 _gateway    255.255.255.255 UGH  0   0    0 wlp2s0  
 199.202.117.191 _gateway    255.255.255.255 UGH  600  0    0 wlp2s0  

Disconnect VPN


Now we disconnect the VPN connection by issuing the below command.

 [spameggs@foobar ~]$ nmcli connection down VPN_2   
 Connection 'VPN_2' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)  



Thursday, February 22, 2018

Red Hat Cluster Part 8: Convert HA Cluster from Active/Passive to Active/Active

Recently, we had to convert an HA Cluster from Active/Passive  to Active/Active mode. So I thought of making a blog post for future reference. The scenario is as follows:

  • Operating System: CentOS 7.7
  • Cluster Mode: 2 Node Active/Passive
  • Cluster Manager: Pacemaker/Corosync
  • Shared Storage LVM: HA-LVM

Since the shared storage was configured as LVM resource using HA-LVM configuration, we had to reconfigure LVM to be managed by DLM, CLVMD and formatted as GFS2.

Remove HA-LVM Configuration

The first step in this process was to remove the HA-LVM configuration done previously. The steps used to configure HA-LVM are as follows.

While configuring HA-LVM on both nodes we ensure that the locking_type is set to 1 and use_lvmetad is set to 0 in the file /etc/lvm/lvm.conf  by issuing the following command disabling lvmetad processes.

 # lvmconf --enable-halvm --services --startstopservices  

Then in the same file in the volume_list we list all the Volume Group names that are not controlled by the Cluster but by the OS as given below on both nodes.

 volume_list = [ "centos_root", "centos_home" ]  

We rebuilt the initramfs boot image and rebooted both the nodes.

Now, we undo the above settings on both nodes.

1. Set use_lvmetad to 0 and locking_type to 3 in the file /etc/lvm/lvm.conf and stop lvm2-lvmetad service.

[root@node01 ~]# cat /etc/lvm/lvm.conf | grep use_lvmetad  
      use_lvmetad = 0  
[root@node01 ~]# cat /etc/lvm/lvm.conf | grep locking_type  
      locking_type = 3 
[root@node01 ~]# systemctl stop lvm2-lvmetad.service  

[root@node02 ~] # cat /etc/lvm/lvm.conf | grep use_lvmetad  
      use_lvmetad = 0  
[root@node02 ~]# cat /etc/lvm/lvm.conf | grep locking_type  
      locking_type = 3 
[root@node02 ~] # systemctl stop lvm2-lvmetad.service  

2. Comment the volume_list parameter in the file /etc/lvm/lvm.conf.

[root@node01 ~] # cat /etc/lvm/lvm.conf | grep volume_list  
     # volume_list = [ "centos_root", "centos_home" ]  
[root@node02 ~] # cat /etc/lvm/lvm.conf | grep volume_list  
     # volume_list = [ "centos_root", "centos_home" ]  

3. Rebuild the initramfs boot image and reboot both the nodes.

Before rebuilding the initramfs boot image we take a backup of the initramfs boot image.

[root@node01 ~] # cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak  
[root@node02 ~] # cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak  

Now we rebuild the initramfs boot image and reboot the nodes.

[root@node01 ~]# dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
[root@node02 ~]# dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)

[root@node01 ~]# reboot
[root@node02 ~]# reboot

Configure CLVMD for Active/Active Mode

After removing HA-LVM configuration, we removed the previous Logical Volumes, Volume Groups and Physical Volumes that were on the shared storage. Since there was no data, we proceeded with the above step for ease. 

Then we re-created the PV, VG and LV for use in cluster mode and managed by CLVMD.

1. Install required packages.

We install lvm2-cluster and gfs2-utils packages.


 [root@node01 ~]# yum install lvm2-cluster gfs2-utils  
 [root@node02 ~]# yum install lvm2-cluster gfs2-utils  


2. Set no_quorum_policy to freeze in order to prevent fencing of all nodes when quorum is lost.

 [root@node01 ~]# pcs property set no-quorum-policy=freeze  

3. Setup DLM and CLVMD cluster resource.

Before proceeding with this step it is important to note that Cluster Fencing (STONITH) needs to be preconfigured. Otherwise the DLM and CLVMD resources do not activate the LVM and the shared storage will not be accessible. We had already configured iLO5 fencing as shown below.

[root@node01 ~]# pcs stonith create HPEiLO_N01_FENCE fence_ilo5_ssh \
ipaddr="192.168.3.5"login="fenceuser1" secure="true" passwd="password" \
method="onoff" delay=10 pcmk_reboot_action="reboot" pcmk_host_list="node01"

[root@node01 ~]# pcs stonith create HPEiLO_N02_FENCE fence_ilo5_ssh \
ipaddr="192.168.3.6" login="fenceuser2" secure="true" passwd="password" \
method="onoff" pcmk_reboot_action="reboot" pcmk_host_list="node02"

 [root@node01 ~]# pcs status
.........
HPEiLO_N01_FENCE      (stonith:fence_ilo5_ssh):      Started node01  
HPEiLO_N02_FENCE      (stonith:fence_ilo5_ssh):      Started node02  
.........

Setting up DLM resource.

[root@node01 ~]# pcs resource create dlm ocf:pacemaker:controld op \
monitor interval=30s on-fail=fence clone interleave=true ordered=true  

Setting up CLVMD resource.

[root@node01 ~]# pcs resource create clvmd ocf:heartbeat:clvm op \
monitor interval=30s on-fail=fence clone interleave=true ordered=true  

Setting DLM and CLVMD start up order and dependency. First the DLM resource must start then the CLVMD resource. Both must run on the same node.

[root@node01 ~]# pcs constraint order start dlm-clone then clvmd-clone
Adding dlm-clone clvmd-clone (kind: Mandatory) (Options: first-action=start then-action=start)
[root@node01 ~]# pcs constraint colocation add clvmd-clone with dlm-clone

We can verify if the above resources have been created by checking the status of the cluster.

[root@node01 ~]# pcs status
Clone Set: dlm-clone [dlm]
     Started: [ node01 node02 ]
Clone Set: clvmd-clone [clvmd]
     Started: [ node01 node02 ]

Configure GFS2 File System

Since we have deleted the previous LVM of the shared storage, we need to recreate the LVM and format as GFS2 Filesystem.

1. Create Clustered LVM

[root@node01 ~]# pvcreate /dev/mapper/shared01
[root@node01 ~]# vgcreate -Ay -cy vg_shared01 /dev/mapper/shared01
[root@node01 ~]# lvcreate -l 100%FREE -n lv_shared01 vg_shared01

The first command creates a Physical Volume of the shared storage mapped as device file /dev/mapper/shared01.

The second command creates a Volume Group vg_shared01 with the attributes Clustered (-cy) and Autobackup (-Ay) enabled.

The third command creates a Logical Volume lv_shared01 utilizing all the free space available in the Volume Group.

2. Create GFS2 file system

[root@node01 ~]# mkfs.gfs2 -p lock_dlm -j 2 -t dev_cluster:dev01 \
/dev/vg_shared01/lv_shared01

The above command formats the LVM device created in step 1 as GFS2 file system. It is recommended to only use GFS2 as the file system for Active/Active shared storage. For Active/Passive cluster EXT4 or XFS file system can be used as well.

The option -p stands for LockProtoName. We used lock_dlm. 

The option -j represents the number of journals. It is important to note that this number should be equal to the number of nodes in the cluster. So we have set this option to 2 journals. It creates one journal per system that mounts the file system.

The -t option stands for LockTableName. It's format is clustername:fsname. Clustername name must the same as the name of the cluster and fsname is a unique name of the GFS2 file system to differentiate from other file system names.

All the details are described here.

3. Create Filesystem resource to manage and mount the file system.

The /shared01 directory must be created on both the nodes before the following command is run since the command mounts the device to the directory /shared01 on both the nodes simultaneously.

[root@node01 ~]# pcs resource create FS_shared01 ocf:heartbeat:Filesystem \
device="/dev/vg_shared01/lv_shared01" directory="/shared01" fstype="gfs2" --clone

4. Set CLVMD and Filesystem resource startup order and dependency.

[root@node01 ~]# pcs constraint order start clvmd-clone then FS_shared01-clone
Adding dlm-clone clvmd-clone (kind: Mandatory) (Options: first-action=start then-action=start)
[root@node01 ~]# pcs constraint colocation add FS_shared01-clone with clvmd-clone

Configure Virtual IP Resource 

First we create the Virtual IP resource with the IP and subnet details.

[root@node01 ~]# pcs resource create VirtualIP IPaddr2 ip=198.168.90.17 cidr_netmask=24

Then we clone the Virtual IP resource. This step also depends on the application usage. If the application in the cluster requires load-balancing and failover, then this configuration is useful.

If only shared storage needs to be active on both the nodes and Virtual IP only connects to the application on one node at a time, then we do not need to clone the Virtual IP resource. If both shared storage and VIP only need to be active on a single node then an Active/Passive cluster mode is sufficient.

[root@node01 ~]# pcs resource clone VirtualIP \
globally-unique=true clone-max=2 clone-node-max=2
[root@node01 ~]# pcs resource update VirtualIP clusterip_hash=sourceip

The clone options are:

1. Globally-unique=true

When set true,  each copy of the clone performs different functions.

2. Clone-max=2

The number of resources to start, in this case 2.

3. Clone-node-max=2

The number of copies of resource to be started on a single node, in this case 2.

The clusterip_hash decides which hosts receive and process which requests. The parameter we have chosen is sourceip. The source IP address of incoming packets are hashed and the nodes each will receive certain hashes to process the requests.

Then we set the startup order and dependency of FS_shared01-clone and Virtual IP resource.

[root@node01 ~]# pcs constraint order start FS_shared01-clone then VirtualIP-clone
Adding dlm-clone clvmd-clone (kind: Mandatory) (Options: first-action=start then-action=start)
[root@node01 ~]# pcs constraint colocation add VirtualIP-clone with FS-shared01-clone

Similarly, we can setup other resources as per our requirement like Web Servers, Network File Shares or Database Services.

Finally checking the status of the cluster, we get the below output.

[root@node01 ~]# pcs status
Cluster name: dev_cluster
Stack: corosync

2 nodes configured
10 resources configured

Online: [ node01 node02 ]

Full list of resources:

 HPEiLO_N01_FENCE      (stonith:fence_ilo5_ssh):      Started node01  
 HPEiLO_N02_FENCE      (stonith:fence_ilo5_ssh):      Started node02  
 Clone Set: dlm-clone [dlm]
     Started: [ node01 node02 ]
 Clone Set: clvmd-clone [clvmd]
     Started: [ node01 node02 ]
 Clone Set: FS_shared01-clone [FS_shared01]
     Started: [ node01 node02 ]
 Clone Set: VirtualIP-clone [VirtualIP] (unique)
     VirtualIP:0        (ocf::heartbeat:IPaddr2) Started
     VirtualIP:1        (ocf::heartbeat:IPaddr2) Started

Tuesday, February 6, 2018

Red Hat Cluster Part 6: Permanently Removing Cluster Services

In this final post of this series (probably not!), we are going to configure the two nodes to completely remove the cluster services.

Stop the cluster services

Check the cluster status

 [root@N2 ~]# clustat  
 Cluster Status for HAcluster @ Fri Feb 1 15:01:46 2019  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  hb1.off.com                             1 Online, rgmanager  
  hb2.off.com                             2 Online, Local, rgmanager  
  /dev/block/8:32                           0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:RS                            hb2.off.com                           started  

Stop and disable the cluster services

First we remove the service using the ccs tool.

 [root@N2 ~]# ccs -h localhost --rmservice RS  

Then we stop and permanently disable the cluster services on both the nodes using a single command.

 [root@N2 ~]# ccs -h localhost --stopall  

Change the Volume Group type

In the second post of this series, I configured HA LVM and the locking type was 1. However, for this post when I re-setup the cluster, I used CLVM for setting up LVM and changed the locking type to 3. The volume group attributes were setup as "cy" meaning "clustered - yes". 

 We can check the status of the volume group of the shared storage. 

 [root@N2 ~]# vgdisplay shared_vg --config 'global {locking_type = 0}' | grep Clustered  
  WARNING: Locking disabled. Be careful! This could corrupt your metadata.  
  Clustered       yes  

Now, we change the volume group from clustered to non-clustered by changing the locking type.

 [root@N2 ~]# vgchange -cn shared_vg --config 'global {locking_type = 0}'  
  WARNING: Locking disabled. Be careful! This could corrupt your metadata.  
  Volume group "shared_vg" successfully changed  

We should note that if the cluster services were still running, the following command would have sufficed to change the volume group attributes.

 [root@N2 ~]# vgchange -cn shared_vg   

Now, the shared_vg volume group is visible.

 [root@N2 ~]# vgs  
  VG    #PV #LV #SN Attr  VSize VFree  
  shared_vg  1  1  0 wz--n- 15.00g  0  
  vg_n2    1  2  0 wz--n- 49.51g  0  

Then we activate the volume group.

 [root@N2 ~]# vgchange -ay shared_vg  
  1 logical volume(s) in volume group "shared_vg" now active  

We can also check the logical volume "ha_lv"

 [root@N2 ~]# lvs  
  LV   VG    Attr    LSize Pool Origin Data% Move Log Cpy%Sync Convert  
  ha_lv  shared_vg -wi-a----- 15.00g  
  lv_root vg_n2   -wi-ao---- 45.63g  
  lv_swap vg_n2   -wi-ao---- 3.88  

Now, we need to mount the LVM device to the mount point.

 [root@N2 ~]# cat /etc/fstab  
 #  
 # /etc/fstab  
 # Created by anaconda on Wed Jan 16 12:03:29 2019  
 #  
 # Accessible filesystems, by reference, are maintained under '/dev/disk'  
 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info  
 #  
 /dev/mapper/vg_n2-lv_root /            ext4  defaults    1 1  
 UUID=01a596ef-a4f8-4e28-9e1b-b54b2b9695aa /boot          ext4  defaults    1 2  
 /dev/mapper/vg_n2-lv_swap swap          swap  defaults    0 0  
 tmpfs          /dev/shm        tmpfs  defaults    0 0  
 devpts         /dev/pts        devpts gid=5,mode=620 0 0  
 sysfs          /sys          sysfs  defaults    0 0  
 proc          /proc          proc  defaults    0 0  
 /dev/shared_vg/ha_lv  /ClusterMountPoint   ext4 defaults 1 2  

We can confirm the mount point below after mounting the mount points using the commands `mount -a` and `df -h`.

 [root@N2 ~]# mount -a  
 [root@N2 ~]# df -h  
 Filesystem          Size Used Avail Use% Mounted on  
 /dev/mapper/vg_n2-lv_root   45G 5.9G  37G 14% /  
 tmpfs            1.9G   0 1.9G  0% /dev/shm  
 /dev/sda1          485M  39M 421M  9% /boot  
 /dev/mapper/shared_vg-ha_lv  15G 153M  14G  2% /ClusterMountPoint  

Finally, we have completed all the steps to remove the cluster services from both the nodes. We can then power off the other node and remove the shared RDM disks. We need to be careful to not tick the option "Delete files from datastore" as the disks are still being used by the second node server N2.



Monday, February 5, 2018

Red Hat Cluster Part 5: Extend Shared Storage

Often times we have the requirement to increase the storage size in the servers. In a clustered environment, the process is similar to that of non-clustered environments. However, since we have setup virtualized nodes for cluster setup in VMware vCenter, we have to perform some extra steps. We will discuss these steps in detail in this blog.

Increase the Volume size from Storage

The first step is to increase the size of the volumes that have been configured as shared RDM disks among the nodes. I have already increased the size of the zvol from 10 GB to 15 GB in free NAS and restarted the iSCSI service in the free NAS.

Check shared RDM disk compatibility settings

There are two settings for the disk compatibility in a RDM disk.
  • Physical - The SCSI commands are not operated by the hypervisor, allows for SAN management of the LUN and useful for low level operations.
  • Virtual - The SCSI commands are operated by the hypervisor, so snapshots are supported. Lots of VMware hypervisor features are supported in this mode.
Detailed explanation can be found here and here.

The RDM disks that I have added before have the compatibility mode set as "Virtual".  


If the compatibility mode was set as "Physical", after re-scanning the iSCSI adapter, the shared disk would need to be re-scanned in the operating system and the shared block device size would be increased.

However, since the RDM disk compatibility mode is set to "Virtual", we need to remove the RDM disk from the virtual machine settings, delete files from the datastore and then re-add it for the changes to the disk to be seen. 

Remove the RDM disk

Before removing the RDM disk we need to note the "Virtual Device Node" controller and the SCSI(X:Y) settings. Here the disk is using "SCSI controller 2" with "SCSI(2:0)" settings.

But first we need to bring the cluster services down and power off both the nodes.

Then we delete the disk and select "Delete files from datastore" option to completely remove the previous disk size settings.



Re-scan the iSCSI Adapter in the Host

The next step is to re-scan the iSCSI software adapter in the ESXi host. We can see in the image below that the changes are imminent after the re-scan.



Re-add the RDM disk

Now, we can re-add the RDM disk and verify the increased size of the disk. We can see that the new capacity of the LUN is 15 GB.


Then we change the new hard disk settings where the compatibility mode is "Virtual", the sharing mode is "Multi-writer" and the virtual device node is set to the same settings as we previously noted which is "SCSI controller 2" and "SCSI(2:0)".

We remove and re-add the RDM disk on both the nodes.

Extend the LVM

We can then power on the virtual machines and extend the disks from the OS. First we need to check that the disk block device size has increased from the terminal by issuing the command "lsblk". Although on boot the disk size should have increased, if the disk size has not increased we can issue the following command to re-scan the device:

 [root@N2 ~]# echo "1" > /sys/class/block/sdc/device/rescan  

We can now check and verify that the block device size has increased to 15 GB.

 [root@N2 ~]# lsblk  
 NAME             MAJ:MIN RM SIZE RO TYPE MOUNTPOINT  
 sr0              11:0  1 1024M 0 rom  
 sda              8:0  0  50G 0 disk  
 ├─sda1             8:1  0 500M 0 part /boot  
 └─sda2             8:2  0 49.5G 0 part  
  ├─vg_redhat-lv_root (dm-0) 253:0  0 45.6G 0 lvm /  
  └─vg_redhat-lv_swap (dm-1) 253:1  0 3.9G 0 lvm [SWAP]  
 sdb              8:16  0  1G 0 disk  
 sdc              8:32  0  15G 0 disk /Test  

The logical volume can be extended by issuing the following commands. These commands should be run on only one of the nodes as it is a shared disk:

 [root@N2 ~]# pvresize /dev/sdc  
 [root@N2 ~]# vgextend shared_vg /dev/sdc  
 [root@N2 ~]# lvresize -l +100% -n ha_lv shared_vg  

Finally we resize the ext4 file system.

 [root@N2 ~]# resize2fs /dev/shared_vg/ha_lv  

 [root@N2 ~]# df -h  
 Filesystem                     Size Used Avail Use% Mounted on  
 /dev/mapper/vg_redhat-lv_root  45G  11G  33G   25%  /  
 tmpfs                          1.9G 26M  1.9G  2%   /dev/shm  
 /dev/sda1                      485M 39M  421M  9%   /boot  
 /dev/mapper/shared_vg-ha_lv    15G  172M 14G   1%   /Test  

Finally, we have increased and verified the size of the shared storage in a clustered environment. 

Friday, January 5, 2018

Red Hat Cluster Part 3: Fail Over Test Cases

I have re-setup a 2 node cluster on Cent OS 6.5 for the purpose of this blog i.e. testing the cluster. The details of host name and IP address are as below:

 [root@N2 ~]# cat /etc/hosts  
 127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4  
 ::1     localhost localhost.localdomain localhost6 localhost6.localdomain6  
 192.168.200.131     N1 N1.off.com  
 192.168.200.132     N2 N2.off.com  
 10.10.10.1       H1 H1.off.com  
 10.10.10.2       H2 H2.off.com  
 192.168.200.135     F1 FIP.off.com  

Checking the status of the cluster.

 [root@N1 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:16:55 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Online, Local, rgmanager  
  N2.off.com                             2 Online, rgmanager  
  /dev/block/8:16                        0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N2.off.com                            started  

The cluster service is running on node 2. We will perform some sanity tests and there should not be any disturbances in the cluster operation.

1. Reboot Active Node N2


 [root@N2 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:18:33 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Online, rgmanager  
  N2.off.com                             2 Online, Local, rgmanager  
  /dev/block/8:16                        0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N2.off.com                            started  
 [root@N2 ~]# reboot  

While rebooting node 2, the cluster service is moving to node 1 by stopping the service on node 2 as shown below.

 [root@N1 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:19:31 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Online, Local, rgmanager  
  N2.off.com                             2 Online, rgmanager  
  /dev/block/8:16                        0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N2.off.com                            stopping  

Now, we can see that the service has started on node 1.

 [root@N1 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:19:48 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Online, Local, rgmanager  
  N2.off.com                             2 Online  
  /dev/block/8:16                        0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N1.off.com                            started  

After node 2 comes up, we check the cluster status.

 [root@N2 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:21:21 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Online, rgmanager  
  N2.off.com                             2 Online, Local, rgmanager  
  /dev/block/8:16                        0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N1.off.com                            started  

We need to make sure the service does not fail back to node 2 as per cluster configuration. We can see above the service is still active on node 1 and will not move to node 2 which was the last owner.

2. Poweroff Active Node N1


As the service is running on node 1, we power off that node

 [root@N1 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:21:11 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Online, Local, rgmanager  
  N2.off.com                             2 Online, rgmanager  
  /dev/block/8:16                        0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N1.off.com                            started  
 [root@N1 ~]# poweroff  
 Broadcast message from root@N1  
     (/dev/pts/1) at 15:21 ...  
 The system is going down for power off NOW!  

We can see that the services are running on node 2 after we power off the first node.

 [root@N2 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:22:55 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Offline  
  N2.off.com                             2 Online, Local, rgmanager  
  /dev/block/8:16                           0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N2.off.com                            started  

3. Power off both nodes and power on both nodes at the same time


I have powered off both the nodes as shown below. For this test we will power on both nodes at the same time and check if the cluster services come up automatically.

After we power on both the nodes, the second node has come up and the cluster service is activated on that node.

 [root@N2 ~]# clustat  
 Cluster Status for officetest @ Fri Dec 7 15:33:14 2018  
 Member Status: Quorate  
  Member Name                           ID  Status  
  ------ ----                           ---- ------  
  N1.off.com                             1 Offline  
  N2.off.com                             2 Online, Local, rgmanager  
  /dev/block/8:16                           0 Online, Quorum Disk  
  Service Name                           Owner (Last)                           State  
  ------- ----                           ----- ------                           -----  
  service:Test Service                   N2.off.com                            started  

When checking the status of node 1, the node is still in the boot process. The cluster is delaying the power on process of node 1 while the cluster service is activated in the node 2.


4. Move services among nodes


Now, we manually move the cluster service among the nodes. The second node is active right now. So we run the following command to move the given service to node 1. The -r specifies the service name and -m specifies the node name where the services are to be moved.

 [root@N2 ~]# clusvcadm -r 'Test Service' -m N1.off.com  
 Trying to relocate service:Test Service to N1.off.com...Success  
 service:Test Service is now running on N1.off.com  

The test is successful and we further move the service to the second node as shown below.

 [root@N1 ~]# clusvcadm -r 'Test Service' -m N2.off.com  
 Trying to relocate service:Test Service to N2.off.com...Success  
 service:Test Service is now running on N2.off.com  

5. Test fencing of nodes


We can also test if the fencing configuration is done correctly by fencing the nodes. For manual fencing we run the following command. The fencing operation is set as reboot. On successful fencing of the node, the node is rebooted by the fencing user configured on vCenter.

 [root@N1 ~]# fence_node N2  
 fence N2 success  

 [root@N2 ~]# fence_node N1  
 fence N1 success