IBM Support

Hands-on for db2ha using active/passive configuration with a shared disk

Technical Blog Post


Abstract

Hands-on for db2ha using active/passive configuration with a shared disk

Body

This article illustrates db2ha using active/passive configuration with some major commands output.
The contents is like as follows.
================================================================
1. environment background
2. db2_install from both nodes
3. db2icrt from node1
4. umount /db2haap from node1 then mount from node2
5. db2icrt from node2
6. create HADB shared database with archive logging
7. db2haicu
8. check for active/passive configuration
================================================================
1. environment background
1-1. topology
node1(haap1): active/passive node
node2(haap2): active/passive node
node3(haap3): shared disk node
(For shared disk implementation, iscsi was used in this document. You can use a shared disk from your SAN server if you have it)
1-2. oslevel and db2level
RHEL 7.4 / "DB2 v11.1.3.3", "s1804271300", "DYN1804271300AMD64"
1-3. shared disk and mount setting.
The "fdisk -l" from both node1 and node2 should show a similar entry like as follows.
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes,
In this example, we use /db2haap for DB2 files sharing. I am sharing my OS commands for your information. By the way, if you have an issue related to file system format and mount, you need to check this with your OS admin. Firstly, we mount /db2haap in the node1(haap1).
[root@haap1 ~]# mkdir /db2haap
[root@haap1 ~]# mkfs.ext3 /dev/sda
mke2fs 1.42.9 (28-Dec-2013)
/dev/sda is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
3932160 inodes, 15728640 blocks
786432 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
480 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
And you need to add an entry in /etc/fstab in both nodes.
/dev/sda    /db2haap    ext3    acl,user_xattr,noauto    0 0
After those, you can issue mount command
[root@haap1 ~]# mount /db2haap
[root@haap1 ~]# mount
...
/dev/sda on /db2haap type ext3 (rw,relatime,stripe=1024,data=ordered)
1-4. user setting
I used the following commands to add users.
groupadd -g 990 db2iadm1
groupadd -g 989 db2fadm1
useradd -u 1002 -g db2iadm1 -m -d /home/db2inst1 -s /usr/bin/ksh db2inst1
useradd -u 1003 -g db2fadm1 -m -d /home/db2fenc1 -s /usr/bin/ksh db2fenc1

1-5. mount mask
Add a mask for the mount point on both hosts:

systemctl mask $(systemd-escape -p --suffix=mount "db2haap")

** IMPORTANT ** This step is to ensure the filesystem does not get mounted during an remote shell login to the instance user. There is a chance that the filesystem may be mounted on multiple systems at the same time which leads to data corruption, if this mask is not applied correctly.

2. db2_install from both nodes
tip: TSAMP installation could fail if you don't have "perl-Sys-Syslog". Please install this first before db2_install in both nodes.
./db2_install -b /opt/ibm/db2/V111M33A -p SERVER -y
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no]
no
DB2 installation is being initialized.
Total number of tasks to be performed: 58
Total estimated time for all tasks to be performed: 2464 second(s)
Task #1 start
Description: Checking license agreement acceptance
Estimated time 1 second(s)
Task #1 end
...
The execution completed successfully.
3. db2icrt from node1
3-1. home directory setting for db2icrt
We will use /db2haap/db2home as a home directory. To use it, we need the following steps.
mkdir /db2haap/db2home
chown -R db2inst1.db2iadm1 /db2haap
usermod -d /db2haap/db2home db2inst1
cp -f /home/db2inst1/.profile /db2haap/db2home
cp -f /home/db2inst1/.kshrc /db2haap/db2home
3-2. db2icrt
[root@haap1 db2home]# /opt/ibm/db2/V111M33A/instance/db2icrt -p db2c_db2inst1 -u db2fenc1 db2inst1
DBI1446I  The db2icrt command is running.
...
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.24121".
DBI1070I  Program db2icrt completed successfully.
4. umount /db2haap from node1 then mount from node2
4-1. umount /db2haap from node1
4-2. mount /db2haap from node2
- You can see the sqllib already exists in /db2haap/db2home because it was created by db2icrt from node1
[root@haap2 ~]# mkdir /db2haap
[root@haap2 ~]# mount /db2haap
[root@haap2 ~]# ls -al /db2haap
total 24
drwxr-xr-x   4 db2inst1 db2iadm1  4096 Sep 10 22:40 .
dr-xr-xr-x. 19 root     root       276 Sep 10 22:55 ..
drwxr-xr-x   6 db2inst1 db2iadm1  4096 Sep 10 22:45 db2home
drwx------   2 db2inst1 db2iadm1 16384 Sep 10 22:26 lost+found
[root@haap2 ~]# ls -al /db2haap/db2home/
total 36
drwxr-xr-x  6 db2inst1 db2iadm1 4096 Sep 10 22:45 .
drwxr-xr-x  4 db2inst1 db2iadm1 4096 Sep 10 22:40 ..
drwxr-xr-x  3 db2inst1 db2iadm1 4096 Sep 10 22:44 .config
drwxr-xr-x  3 db2inst1 db2iadm1 4096 Sep 10 22:44 .ibm
-rw-r--r--  1 root     root      172 Sep 10 22:43 .kshrc
drwxr-xr-x  3 db2inst1 db2iadm1 4096 Sep 10 22:44 .local
-rw-r--r--  1 root     root      173 Sep 10 22:44 .profile
-rw-------  1 db2inst1 db2iadm1   38 Sep 10 22:46 .sh_history
drwxrwsr-t 24 db2inst1 db2iadm1 4096 Sep 10 22:45 sqllib
5. db2icrt from node2
5-1. home directory setting for db2icrt
chown -R db2inst1.db2iadm1 /db2haap
usermod -d /db2haap/db2home db2inst1
5-2. remove all files from sqllib.
- We have to create the instance again on node2 since some of the instance files are created on the local disk such as DB2 registry etc.
rm -rf /db2haap/db2home/sqllib
5-3. db2icrt
[root@haap2 ~]# /opt/ibm/db2/V111M33A/instance/db2icrt -p db2c_db2inst1 -u db2fenc1 db2inst1
DBI1446I  The db2icrt command is running.
...
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.26047".
DBI1070I  Program db2icrt completed successfully.
6. create HADB shared database with archive logging
- After creating instance, log in as a instance user and create the HADB.
- For log arch, /db2haap/db2arch is used in this example
[root@haap2 ~]# su - db2inst1
Last login: Tue Sep 10 22:58:01 PDT 2019 on pts/0
$ mkdir /db2haap/db2arch
$ db2start
09/10/2019 23:02:42     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
$ db2 create db hadb
DB20000I  The CREATE DATABASE command completed successfully.
$ db2 update db cfg for hadb using logarchmeth1 'DISK:/db2haap/db2arch'
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
$ db2 backup database hadb to /dev/null
Backup successful. The timestamp for this backup image is : 20190910230739
$ db2 deactivate database hadb
DB20000I  The DEACTIVATE DATABASE command completed successfully.
$ db2 activate database hadb
DB20000I  The ACTIVATE DATABASE command completed successfully.
7. db2haicu
7-1. preprpnode haap1 haap2
Please run "preprpnode haap1 haap2" on both nodes before db2haicu
7-2. db2haicu
- In this example, I used private network and did not use the virtual IP.
- IP of the node3 was used for Network Quorum
$ db2haicu
Welcome to the DB2 High Availability Instance Configuration Utility (db2haicu).
You can find detailed diagnostic information in the DB2 server diagnostic log file called db2diag.log. Also, you can use the utility called db2pd to query the status of the cluster domains you create.
For more information about configuring your clustered environment using db2haicu, see the topic called 'DB2 High Availability Instance Configuration Utility (db2haicu)' in the DB2 Information Center.
db2haicu determined the current DB2 database manager instance is 'db2inst1'. The cluster configuration that follows will apply to this instance.
db2haicu is collecting information on your current setup. This step may take some time as db2haicu will need to activate all databases for the instance to discover all paths ...
When you use db2haicu to configure your clustered environment, you create cluster domains. For more information, see the topic 'Creating a cluster domain with db2haicu' in the DB2 Information Center. db2haicu is searching the current machine for an existing active cluster domain ...
db2haicu did not find a cluster domain on this machine. db2haicu will now query the system for information about cluster nodes to create a new cluster domain ...
db2haicu did not find a cluster domain on this machine. To continue configuring your clustered environment for high availability, you must create a cluster domain; otherwise, db2haicu will exit.
Create a domain and continue? [1]
1. Yes
2. No
1
Create a unique name for the new domain:
db2ha
Nodes must now be added to the new domain.
How many cluster nodes will the domain 'db2ha' contain?
2
Enter the host name of a machine to add to the domain:
haap2
Enter the host name of a machine to add to the domain:
haap1
db2haicu can now create a new domain containing the 2 machines that you specified. If you choose not to create a domain now, db2haicu will exit.
Create the domain now? [1]
1. Yes
2. No
1
Creating domain 'db2ha' in the cluster ...
Creating domain 'db2ha' in the cluster was successful.
You can now configure a quorum device for the domain. For more information, see the topic "Quorum devices" in the DB2 Information Center. If you do not configure a quorum device for the domain, then a human operator will have to manually intervene if subsets of machines in the cluster lose connectivity.
Configure a quorum device for the domain called 'db2ha'? [1]
1. Yes
2. No
1
The following is a list of supported quorum device types:
  1. Network Quorum
Enter the number corresponding to the quorum device type to be used: [1]
1
Specify the network address of the quorum device:
172.16.180.167
Configuring quorum device for domain 'db2ha' ...
Configuring quorum device for domain 'db2ha' was successful.
The cluster manager found the following total number of network interface cards on the machines in the cluster domain: '3'.  You can add a network to your cluster domain using the db2haicu utility.
Create networks for these network interface cards? [1]
1. Yes
2. No
1
Enter the name of the network for the network interface card: 'eth0' on cluster node: 'haap1.fyre.ibm.com'
1. Create a new public network for this network interface card.
2. Create a new private network for this network interface card.
3. Skip this step.
Enter selection:
2
Are you sure you want to add the network interface card 'eth0' on cluster node 'haap1.fyre.ibm.com' to the network 'db2_private_network_0'? [1]
1. Yes
2. No
1
Adding network interface card 'eth0' on cluster node 'haap1.fyre.ibm.com' to the network 'db2_private_network_0' ...
Adding network interface card 'eth0' on cluster node 'haap1.fyre.ibm.com' to the network 'db2_private_network_0' was successful.
Enter the name of the network for the network interface card: 'eth0' on cluster node: 'haap2.fyre.ibm.com'
1. db2_private_network_0
2. Create a new public network for this network interface card.
3. Create a new private network for this network interface card.
4. Skip this step.
Enter selection:
1
Are you sure you want to add the network interface card 'eth0' on cluster node 'haap2.fyre.ibm.com' to the network 'db2_private_network_0'? [1]
1. Yes
2. No
1
Adding network interface card 'eth0' on cluster node 'haap2.fyre.ibm.com' to the network 'db2_private_network_0' ...
Adding network interface card 'eth0' on cluster node 'haap2.fyre.ibm.com' to the network 'db2_private_network_0' was successful.
Enter the name of the network for the network interface card: 'eth1' on cluster node: 'haap1.fyre.ibm.com'
1. db2_private_network_0
2. Create a new public network for this network interface card.
3. Create a new private network for this network interface card.
4. Skip this step.
Enter selection:
4
Retrieving high availability configuration parameter for instance 'db2inst1' ...
The cluster manager name configuration parameter (high availability configuration parameter) is not set. For more information, see the topic "cluster_mgr - Cluster manager name configuration parameter" in the DB2 Information Center. Do you want to set the high availability configuration parameter?
The following are valid settings for the high availability configuration parameter:
  1.TSA
  2.Vendor
Enter a value for the high availability configuration parameter: [1]
1
Setting a high availability configuration parameter for instance 'db2inst1' to 'TSA'.
Now you need to configure the failover policy for the instance db2inst1. The failover policy determines the machines on which the cluster manager will restart the database manager if the database manager is brought offline unexpectedly.
The following are the available failover policies:
  1. Local Restart -- during failover, the database manager will restart in place on the local machine
  2. Round Robin -- during failover, the database manager will restart on any machine in the cluster domain
  3. Active/Passive -- during failover, the database manager will restart on a specific machine
  4. M+N -- during failover, the database partitions on one machine will failover to any other machine in the cluster domain (used with DPF instances)
  5. Custom -- during failover, the database manager will restart on a machine from a user-specified list
Enter your selection:
3
You can identify mount points that are noncritical for failover. For more information, see the topic 'Identifying mount points that are noncritical for failover' in the DB2 Information Center.  Are there any mount points that you want to designate as noncritical? [2]
1. Yes
2. No
Active/Passive failover policy was chosen. You need to specify the host names of an active/passive pair.
Enter the host name for the active cluster node:
haap2
Enter the host name for the passive cluster node:
haap1
Adding DB2 database partition '0' to the cluster ...
Adding DB2 database partition '0' to the cluster was successful.
Do you want to configure a virtual IP address for the DB2 partition: '0'? [2]
1. Yes
2. No
2
The following databases can be made highly available:
  Database: HADB
Do you want to make all active databases highly available? [1]
1. Yes
2. No
1
Adding database 'HADB' to the cluster domain ...
Adding database 'HADB' to the cluster domain was successful.
All cluster configurations have been completed successfully. db2haicu exiting ...
8. check for active/passive configuration
$ lsrpdomain
Name  OpState RSCTActiveVersion MixedVersions TSPort GSPort
db2ha Online  3.2.3.1           No            12347  12348
$ lsrpnode
Name  OpState RSCTVersion
haap2 Online  3.2.3.1
haap1 Online  3.2.3.1
$ lssam
Online IBM.ResourceGroup:db2_db2inst1_0-rg Nominal=Online
        |- Online IBM.Application:db2_db2inst1_0-rs
                |- Offline IBM.Application:db2_db2inst1_0-rs:haap1
                '- Online IBM.Application:db2_db2inst1_0-rs:haap2
        '- Online IBM.Application:db2mnt-db2haap-rs
                |- Offline IBM.Application:db2mnt-db2haap-rs:haap1
                '- Online IBM.Application:db2mnt-db2haap-rs:haap2
Online IBM.Equivalency:db2_db2inst1_0-rg_group-equ
        |- Online IBM.PeerNode:haap1:haap1
        '- Online IBM.PeerNode:haap2:haap2
Online IBM.Equivalency:db2_private_network_0
        |- Online IBM.NetworkInterface:eth0:haap1
        '- Online IBM.NetworkInterface:eth0:haap2
For further information for db2haicu, please check the following link.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

UID

ibm13285717