Deploy High Availability Cluster on RHEL 8 Using Shared Storage

Lab Environment:

Prerequisites:

  • Operating System RHEL 8
  • Red Hat Developer Subscription (register here)
  • Node Cluster can reach Node Storage

Prepare All Nodes:

# subscription-manager register 
# subscription-manager attach --auto
# subscription-manager repos --enable=rhel-8-for-x86_64-highavailability-rpms
# dnf update -y
192.168.1.218   ha1 ha1.localdomain
192.168.1.219 ha2 ha2.localdomain
192.168.1.220 ha-storage ha-storage.localdomain

Shared Storage

Setup Cluster Nodes

[root@ha1 ~]# dnf install -y pcs pacemaker fence-agents-all pcp-zeroconf psmisc policycoreutils-python-utils lvm2 chrony iscsi-initiator-utils
[root@ha1 ~]# firewall-cmd --permanent --add-service=high-availability
[root@ha1 ~]# firewall-cmd --reload
[root@ha1 ~]# systemctl start pcsd
[root@ha1 ~]# systemctl enable --now pcsd
[root@ha1 ~]# systemctl status pcsd
[root@ha1 ~]# passwd hacluster
[root@ha1 ~]# pcs host auth ha1.localdomain ha2.localdomain
[root@ha1 ~]# pcs cluster setup mycluster --start ha1.localdomain ha2.localdomain
[root@ha1 ~]# pcs cluster enable --all
[root@ha1 ~]# systemctl enable corosync && systemctl enable pacemaker
[root@ha1 ~]# corosync-cfgtool -s
[root@ha1 ~]# corosync-cmapctl | grep members
[root@ha1 ~]# pcs status
[root@ha1 ~]# pcs property set stonith-enabled=false
[root@ha1 ~]# pcs status
[root@ha1 ~]# vi /etc/lvm/lvm.conf
[root@ha1 ~]# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak
[root@ha1 ~]# dracut -f -v
[root@ha1 ~]# reboot

Setup Shared Storage (iSCSI)

[root@ha-storage ~]# yum install -y targetcli 
[root@ha-storage ~]# timedatectl set-ntp yes
[root@ha-storage ~]# fdisk -l | grep -i sd
[root@ha-storage ~]# pvcreate /dev/sdb
[root@ha-storage ~]# vgcreate vg_iscsi /dev/sdb
[root@ha-storage ~]# lvcreate -l 100%FREE -n lv_iscsi vg_iscsi
[root@ha1 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994–05.com.redhat:dd802b97ab60
[root@ha2 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994–05.com.redhat:1cc56373abf8
[root@ha-storage ~]# targetcli
[root@ha-storage ~]# systemctl enable --now target
[root@ha-storage ~]# systemctl status target
[root@ha-storage ~]# firewall-cmd --permanent --add-port=3260/tcp
[root@ha-storage ~]# firewall-cmd --reload
[root@ha1 ~]# timedatectl set-ntp yes

Discover Shared Storage

[root@ha1 ~]# iscsiadm -m discovery -t st -p 192.168.1.220Output:
192.168.1.220:3260,1 iqn.2003-01.org.linux-iscsi.ha-storage.x8664:sn.4cb9b5f7b85c
[root@ha1 ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.ha-storage.x8664:sn.4cb9b5f7b85c -p 192.168.1.220 -lOutput:
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.ha-storage.x8664:sn.4cb9b5f7b85c, portal: 192.168.1.220,3260]
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.ha-storage.x8664:sn.4cb9b5f7b85c, portal: 192.168.1.220,3260] successful.
[root@ha1 ~]# systemctl enable --now iscsid
[root@ha1 ~]# systemctl status iscsid

Setup and Create LVM

[root@ha1 ~]# fdisk -l | grep -i sd
[root@ha1 ~]# lsblk
[root@ha1 ~]# pvcreate /dev/sdb
[root@ha1 ~]# vgcreate vgpool /dev/sdb
[root@ha1 ~]# vgs -o+systemid
[root@ha1 ~]# lvcreate -l 100%FREE -n lvdata vgpool
[root@ha1 ~]# mkfs.ext4 /dev/vgpool/lvdata
[root@ha1 ~]# mkdir -p /share
[root@ha1 ~]# mount /dev/vgpool/lvdata /share
[root@ha1 ~]# echo "tes HA" > /share/tes-HA.txt
[root@ha1 ~]# df -h /share/tes-HA.txt
[root@ha1 ~]# cat /share/tes-HA.txt
[root@ha1 ~]# umount /share

Setup Cluster Resources

[root@ha1 ~]# pcs resource create Virtual_IP IPaddr2 ip=192.168.1.100 cidr_netmask=24 op monitor interval=30s
[root@ha1 ~]# pcs resource create My_VG ocf:heartbeat:LVM-activate vgname=vgpool activation_mode=exclusive vg_access_mode=system_id --group HA-LVM
[root@ha1 ~]# pcs resource create My_FS Filesystem device="/dev/mapper/vgpool-lvdata" directory="/share" fstype="ext4" --group HA-LVM
[root@ha1 ~]# pcs status
[root@ha1 ~]# pcs constraint order Virtual_IP then My_FS
[root@ha1 ~]# pcs constraint colocation add My_FS with Virtual_IP INFINITY
[root@ha1 ~]# pcs constraint location My_VG prefers ha1.localdomain=100
[root@ha1 ~]# pcs constraint location My_VG prefers ha2.localdomain=50

Test Failover LVM-HA

  • Node ha1
[root@ha1 ~]# df -h /share
[root@ha1 ~]# cat /share/tes-HA.txt
[root@ha1 ~]#
[root@ha1 ~]# pcs node standby ha1.localdomain
[root@ha1 ~]# pcs status
  • Node ha2
[root@ha2 ~]# df -h /share
[root@ha2 ~]# cat /share/tes-HA.txt
[root@ha2 ~]#
[root@ha2 ~]# lsblk
[root@ha2 ~]# pcs status
  • Node ha1
[root@ha1 ~]# pcs node unstandby ha1.localdomain
[root@ha1 ~]#
[root@ha1 ~]# pcs status
[root@ha1 ~]# df -h /share
[root@ha1 ~]# cat /share/tes-HA.txt

--

--

--

Cloud Consultant | RHCSA | RHCE in Red Hat OpenStack | Google Cloud ACE | AWS SAA | LinkedIn: https://www.linkedin.com/in/achchusnulchikam

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creativity through limitation: PICO-8 — Fantasy Console

Top 10 Benefits of Continuous Integration & Continuous Delivery

SPARK DEPLOYMENT MODE

The Secret To Learning A New Language Faster

How to deploy a PyTorch model in minutes

How an agile management tool (GitScrum) can increase team productivity

Build a Simple Rule Based Chatbot in Python

Goat Protocol Presale Started!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ach.Chusnul Chikam

Ach.Chusnul Chikam

Cloud Consultant | RHCSA | RHCE in Red Hat OpenStack | Google Cloud ACE | AWS SAA | LinkedIn: https://www.linkedin.com/in/achchusnulchikam

More from Medium

Getting Started VMware Tanzu Community Edition (Part 3)

PART 1 — Red Hat OpenStack Platform (OSP) Service Telemetry Framework (STF) with OpenShift…

Monitoring Camel-K applications on Openshift using the Fuse Console — Part 2 (Kamelets)

Load Balancing With HAProxy On AWS Instance Using Ansible Playbook (12.2)