Creating an HADR Db2 instance on a Pacemaker-managed Linux cluster

You can create and administer a Pacemaker-managed Db2 Linux cluster that is configured for High Availability Disaster Recovery (HADR) by using the Db2® cluster manager (db2cm) utility.

Before you begin

Important: To run the db2cm utility as the root user, ensure the DB2INSTANCE environment variable is set to the instance owner.
Before proceeding with the configuration, ensure that the following system dependencies are in place:
  • The Pacemaker cluster software stack must be installed on all hosts in the cluster. For more information, refer to Installing the Pacemaker cluster software stack.
  • The Db2 instances and HADR database should be configured and online.
  • The HADR database must be configured with either SYNC or NEARSYNC as the HADR_SYNCMODE .
  • The HADR database HADR_PEER_WINDOW must be configured to be at least 60 seconds.

About this task

The following placeholders are used in the command statements throughout this procedure:
  • <hostname1> and <hostname2> are the short host names for the primary and standby network interfaces in the cluster.
  • <network_interface_name> is the name of the device on the cluster.
  • <database_name> is the name of the Db2 database on the HADR database resource.
  • <instance_name> is the name of the Db2 instance on the cluster

For this procedure, you must run all of the steps as the root user on one of the hosts. There is no need to run them on both hosts.

Procedure

  1. Create the Pacemaker cluster and the public network resources by running the following command.
    ./sqllib/bin/db2cm -create -cluster -domain <domain name> 
    -host <hostname1> -publicEthernet <network_interface_name>
    -host <hostname2> -publicEthernet <network_interface_name>
    Note: You need only to run this step once.
  2. Create the instance resources by running the following commands:
    ./sqllib/bin/db2cm -create -instance <instance_name> –host <hostname1>
    
    ./sqllib/bin/db2cm -create -instance <instance_name> –host <hostname2>
    ./sqllib/bin/db2cm -create -instance <instance_name> -host <hostname1>
    ./sqllib/bin/db2cm -create -instance <instance_name> -host <hostname2>
  3. Verify the cluster by running the db2cm -status command:
    ./sqllib/bin/db2cm -status
    Note:
    • The Online parameter needs to include both hosts.
    • db2_<hostname>_<network_interface_name> is the public Ethernet resource in the cluster domain.
  4. Create a new database and configure HADR on the new database. For more information on configuring HADR, refer to Initializing High Availability Disaster Recovery (HADR). If your database already exists and HADR is configured, proceed to step 5.
  5. Create the HADR database resources.
    ./sqllib/bin/db2cm -create -db <database_name> -instance <instance_name>
  6. Optional: Create the VIP resources for the newly created database.
    ./sqllib/bin/db2cm -create -primaryVIP <IP_address> -db <database_name> –instance <instance_name>
  7. Verify the cluster again using following command:
    ./sqllib/bin/db2cm -status
    Note: Ensure that the output contains the following information:
    • The Online parameter includes the IP addresses of both hosts.
    • The db2_<hostname>_<network_interface_name> public Ethernet resource exists in the cluster domain. Ensure that one resource exists on each host, and that both resources are labeled with the Started state.
    • A db2_<instance_name>_<hostname>_0 instance resource exists for every Db2 instance.
    • The database resource has Promoted and Unpromoted started on the respective host.

Examples

The following example shows the command syntax and output for creating the Pacemaker cluster and the public network resources, where pcmk-test-hadr-srv-1 and pcmk-test-hadr-srv-2 are the host names of the nodes in your cluster, hadom is the domain name and eth1 is the network interface (device) name of each host (see step 1):
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -create -cluster -domain hadom -host pcmk-test-hadr-srv-1 -publicEthernet eth1 -host pcmk-test-hadr-srv-2 -publicEthernet eth1
Public Ethernet resource 'eth1' on 'pcmk-test-hadr-srv-1' created successfully.
Public Ethernet resource 'eth1' on 'pcmk-test-hadr-srv-2' created successfully.
Domain created successfully.
The following example shows the command syntax and output for creating the instance cluster domain for the Db2 instance db2inst1 (see step 2):
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -create -instance db2inst1 -host pcmk-test-hadr-srv-1
Sample output:
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -create -instance db2inst1 -host pcmk-test-hadr-srv-1
Instance resource 'db2inst1' on 'pcmk-test-hadr-srv-1' created successfully.
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -create -instance db2inst1 -host pcmk-test-hadr-srv-2
Instance resource 'db2inst1' on 'pcmk-test-hadr-srv-2' created successfully.
The following example shows sample output from running db2cm -status to verify the cluster before creating the Db2 databases, HADR resources, and VIP resources (see step 3):
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -status
2024-12-11-10.47.29
-------------------
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: pcmk-test-hadr-srv-1 (version 2.1.7-4.db2pcmk.el9.2-75a4166) - partition with quorum
* Last updated: Wed Dec 11 10:47:29 2024 on pcmk-test-hadr-srv-1
* Last change: Wed Dec 11 10:41:49 2024 by root via root on pcmk-test-hadr-srv-2
* 2 nodes configured
* 4 resource instances configured
Node List:
* Online: [ pcmk-test-hadr-srv-1 pcmk-test-hadr-srv-2 ]
Full List of Resources:
* db2_ethmonitor_pcmk-test-hadr-srv-1_eth1 (ocf:heartbeat:db2ethmon): Started pcmk-test-hadr-srv-1
* db2_ethmonitor_pcmk-test-hadr-srv-2_eth1 (ocf:heartbeat:db2ethmon): Started pcmk-test-hadr-srv-2
* db2_pcmk-test-hadr-srv-1_db2inst1_0 (ocf:heartbeat:db2inst): Started pcmk-test-hadr-srv-1
* db2_pcmk-test-hadr-srv-2_db2inst1_0 (ocf:heartbeat:db2inst): Started pcmk-test-hadr-srv-2
QDevice Information:
* Not configured
The following example shows the command syntax for creating the HADR resources on a database named GT on the Db2 instance db2inst1 (see step 5) :
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -create -db GT -instance db2inst1
Database resource 'GT' created successfully.
The following example shows the command syntax for creating the VIP resource on a database named GT on the Db2 instance db2inst1 (see step 6):
INSTANCE-HOME/sqllib/bin/db2cm -create -primaryVIP <IP address> -db SAMPLE –instance db2inst1
The following example shows the output from running db2cm -status to verify the cluster after creating the Db2 databases, HADR resources, and VIP resources (see step 7):
[root@pcmk-test-hadr-srv-1 db2inst1]# ./sqllib/bin/db2cm -status
2024-12-11-10.59.53
-------------------
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: pcmk-test-hadr-srv-1 (version 2.1.7-4.db2pcmk.el9.2-75a4166) - partition with quorum
* Last updated: Wed Dec 11 10:59:53 2024 on pcmk-test-hadr-srv-1
* Last change: Wed Dec 11 10:50:12 2024 by root via root on pcmk-test-hadr-srv-1
* 2 nodes configured
* 7 resource instances configured
Node List:
* Online: [ pcmk-test-hadr-srv-1 pcmk-test-hadr-srv-2 ]
Full List of Resources:
* db2_ethmonitor_pcmk-test-hadr-srv-1_eth1 (ocf:heartbeat:db2ethmon): Started pcmk-test-hadr-srv-1
* db2_ethmonitor_pcmk-test-hadr-srv-2_eth1 (ocf:heartbeat:db2ethmon): Started pcmk-test-hadr-srv-2
* db2_pcmk-test-hadr-srv-1_db2inst1_0 (ocf:heartbeat:db2inst): Started pcmk-test-hadr-srv-1
* db2_pcmk-test-hadr-srv-2_db2inst1_0 (ocf:heartbeat:db2inst): Started pcmk-test-hadr-srv-2
* Clone Set: db2_db2inst1_db2inst1_GT-clone [db2_db2inst1_db2inst1_GT] (promotable):
\* Promoted: \[ pcmk-test-hadr-srv-1 \] \* Unpromoted: \[ pcmk-test-hadr-srv-2 \]
* db2_db2inst1_db2inst1_GT-primary-VIP (ocf:heartbeat:IPaddr2): Started pcmk-test-hadr-srv-1
QDevice Information:
* Not configured