High Availability DRBD on RHEL 8

Lab Environment:

Prerequisites:

  • Operating System RHEL 8
  • Red Hat Developer Subscription (register here)

Setup DRBD

Prepare systems, execute on all nodes

# mokutil --sb-state
# lsblk
# pvcreate /dev/sdb
# vgcreate drbdpool /dev/sdb
# lvcreate -n drbddata -l100%FREE drbdpool
# subscription-manager register
# subscription-manager attach --auto
# subscription-manager repos --enable=rhel-8-for-x86_64-highavailability-rpms
# dnf repolist
# dnf update

Setup Cluster Nodes

# dnf install pcs pacemaker fence-agents-all pcp-zeroconf psmisc policycoreutils-python-utils chrony -y
# timedatectl set-ntp yes
# systemctl restart chronyd
# timedatectl
# firewall-cmd --permanent --add-service=high-availability
# firewall-cmd --reload
# echo "redhat" | passwd --stdin hacluster
# systemctl enable --now pcsd
# systemctl status pcsd
# pcs host auth rhel-ha1 rhel-ha2
[root@rhel-ha1 ~]# pcs cluster setup mycluster --start rhel-ha1 rhel-ha2
[root@rhel-ha1 ~]# pcs cluster enable --all
[root@rhel-ha1 ~]# systemctl enable corosync && systemctl enable pacemaker
[root@rhel-ha1 ~]# corosync-cfgtool -s
[root@rhel-ha1 ~]# corosync-cmapctl | grep members
[root@rhel-ha1 ~]# pcs status corosync
[root@rhel-ha1 ~]# pcs property set stonith-enabled=false
[root@rhel-ha1 ~]# pcs status

Setup DRBD

# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
dnf install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm -y
# dnf repolist
# dnf search drbd
# dnf install kmod-drbd90.x86_64 drbd90-utils.x86_64 -y
# lsmod | grep -i drbd
# modprobe drbd
# echo drbd > /etc/modules-load.d/drbd.conf
# semanage permissive -a drbd_t
# firewall-cmd --add-port=7789/tcp --permanent
# firewall-cmd --reload
# reboot
# lsmod | grep -i drbd
# cat /etc/drbd.conf
# mv /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.conf.bak
# cat << EOF > /etc/drbd.d/global_common.conf
global {
usage-count no;
}
common {
net {
protocol C;
}
}
EOF

Configure DRBD resource


# cat << EOF > /etc/drbd.d/resource0.res
resource resource0 {
protocol C;
device /dev/drbd0;
disk /dev/drbdpool/drbddata;
meta-disk internal;
on rhel-ha1 {
address 192.168.1.105:7789;
}
on rhel-ha2 {
address 192.168.1.104:7789;
}
}
EOF

Create and Enable DRBD Resource

Each of the following steps must be completed on all the cluster nodes.
# drbdadm create-md resource0
# systemctl enable --now drbd
# drbdadm up resource0
# drbdadm status resource0
Configure DRBD primary server
# drbdadm primary resource0 --force
# cat /proc/drbd
# mkfs.ext4 /dev/drbd0
# mkdir -p /share
# mount /dev/drbd0 /share
# touch /share/DRBD{1..5}
# umount /share
Create a mount point with same name on another cluster nodes
# mkdir /share

Configure the Cluster for the DRBD device

# pcs resource create Virtual_IP IPaddr2 ip=192.168.1.110 cidr_netmask=24 op monitor interval=30s
# pcs resource create DRBD_Data ocf:linbit:drbd drbd_resource=resource0 promotable promoted-max=1 promoted-node-max=1 clone-max=3 clone-node-max=1 notify=true
# pcs resource create DRBD_FS ocf:heartbeat:Filesystem device=/dev/drbd0 directory=/share fstype=ext4
# pcs status
# pcs constraint colocation add DRBD_FS with DRBD_Data-clone INFINITY with-rsc-role=Master
# pcs constraint order promote DRBD_Data-clone then start DRBD_FS kind=mandatory
# pcs constraint order stop DRBD_FS then demote DRBD_Data-clone score=500
# pcs constraint location DRBD_Data-clone prefers rhel-ha1.localdomain=100
# pcs constraint location DRBD_Data-clone prefers rhel-ha2.localdomain=50
# pcs constraint location Virtual_IP prefers rhel-ha1.localdomain=50
Restart resource on the cluster
# pcs resource cleanup
# pcs status

Verify Failover DRBD

--

--

--

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

Our next major update: PvP and Cloud Saving

Working with Oanda’s API, Part 2 — HTTP request and storing data in MongoDB with Golang

Getting Started with Blazor

CADUCEUS: Weekly Report 7

How to customize error messages in Laravel 8

Harmony OS : Step Speed and Geographic Displacement Calculator

Alvin’s Dew Drop Daily — Issue #27

CS285: Setting Up Homework

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

Nexus Installation In Linux Centos

Tired of spreadsheets? Time to invest in more dynamic solutions for your merch planning teams.

Adversary-in-the-middle using Network Sniffing