SlashCurate - Driving Business Innovation with Cutting-Edge Software Solutions

Configure DB2 High Availability using Pacemaker

Author: Neeraj Sharma; Publish date: 2024-12-03 05:27:53


Author: Neeraj Sharma


Environment
Two servers with:
  • OS: RHEL 9.2, 
  • kernel: 5.14.0-427.22.1.el9_4.x86_64
  • Local disk: 100GB
  • Cores: 4, 
  • 16GB RAM
20GB SAN disk (for DB2 data), visible to both servers.

Base packages required:
  • nfs-utils
  • libtool-ltdl
  • automake
  • elfutils-libelf-devel
  • patch
  • make
  • perl
  • kernel-headers
  • kernel-devel
  • NetworkManager-config-server
  • net-tools
  • cpp
  • gcc
  • gcc-c++
  • libxcrypt-compat
  • ksh
  • chrony
  • python3-dnf-plugin-versionlock
  • libstdc++.i686
  • libaio pam.i686
  • mksh 
  • compat-openssl11 
Download libtool-ltdl-devel separately and install it. This package no more is available on default RHEL repository
rpm -i libtool-ltdl-devel-2.4.6-45.el9.x86_64.rpm

Disable SELinux
grubby --update-kernel ALL --args selinux=0

Make directory for DB2 data space
# mkdir /<db2_fs_dir>

Identify the SAN disk to be used for the DB2 data space (below output is representative)
[root@db2wh01 ~]# fdisk -l | grep mapper
Disk /dev/mapper/3600a098038313871673f56754a71544e: 20 GiB, 21474836480 bytes, 41943040 sectors
/dev/mapper/3600a098038313871673f56754a71544e1          2048  8390655 8388608   4G 83 Linux
/dev/mapper/3600a098038313871673f56754a71544e2       8390656 16779263 8388608   4G 83 Linux
/dev/mapper/3600a098038313871673f56754a71544e3      16779264 25167871 8388608   4G 83 Linux

Format the filesystem
# mkfs.<file_system> /dev/<partition_name>

Identify the UUID for the disk
[root@db2wh01 ~]# blkid | grep UUID
/dev/mapper/3600a098038313871673f56754a71544e1: UUID="c17f76e0-4340-477b-97ae-5c4f4373fbf3" TYPE="ext4" PARTUUID="92ad8a9f-01"
/dev/mapper/3600a098038313871673f56754a71544e2: UUID="f79b718c-53bd-40e4-a37d-e089179d4ead" TYPE="ext4" PARTUUID="92ad8a9f-02"
/dev/mapper/3600a098038313871673f56754a71544e3: UUID="f9d2e934-92cb-458d-9c0d-6e379d52b6f6" TYPE="ext4" PARTUUID="92ad8a9f-03"


Create a new entry in the /etc/fstab file on both hosts:
UUID=c17f76e0-4340-477b-97ae-5c4f4373fbf3 /<db2fsdir> <file_system> acl,user_xattr,noauto 0 0

Create DB2 users and assign home directory and shell (if not done already)
groupadd -g 1001 db2iadm
groupadd -g 1002 db2fadm
useradd -u 1101 -g db2iadm -m -d /db2home/db2inst1-s /usr/bin/bash db2inst1
useradd -u 1102 -g db2fadm -m -d /db2home/db2fenc -s /usr/bin/bash db2fenc

chown db2fenc:db2fadm db2fenc/
chown -R db2inst1:db2iadm db2inst1/
chown -R db2inst1:db2iadm /db2home


Disable fault monitor
/opt/ibm/db2/V11.5/bin/db2fmcu -d

Enable password-less SSH between nodes (for root and instance owner id)

Create Pacemaker cluster
db2cm -create -cluster -domain db2ha -host db2node01 -publicEthernet eth0 -host db2node02 -publicEthernet eth0


HADR
db2cm -create -instance db2inst1 -host hostA
db2cm -create -instance db2inst1 -host hostB
ADD DATABASE
db2cm -create -db HADB -instance db2inst1
ADD VIRTUAL IP
db2cm -create -primaryVIP 10.20.1.1 -netmask 21 -db HADB -instance db2inst1
db2cm -create -primaryVIP 10.20.1.1 -netmask 255.255.248.0 -db HADB -instance db2inst1
ADD MOUNT POINTS
db2cm -add -dbMount HADB -partition 0 -instance db2inst1
CHECK STATUS
crm status
crm config show
db2cm -list
CONFIGURE QUORUM
db2cm -create -qdevice db2node03 //any machine having Linux corosync package installed
RUN FROM CLUSTER NODES
corosync-qdevice-tool -s
RUN FROM QUORUM DEVICE
corosync-qdevice-tool -l
ENABLE AUTOMATION FOR PARTITION 0
db2cm -enable -partition 0 -instance db2inst1
ENABLE AUTOMATION FOR ALL PARTITIONS
db2cm -enable -all
Enjoy DB2HA!