IBM Support

Setting up two-node Db2 HADR Pacemaker cluster with Virtual IP on Microsoft Azure

How To


Summary

Setting up Virtual IP (VIP) for HADR enabled database provides a common connection point for clients without the need to disclose the actual IP address of the Primary and Standby server for the database. In the event of a failover, the client can still connect to the new Primary by using the VIP, effectively achieving automatic client reroute at the network level. The prerequisite for VIP setup is for the primary and standby servers' IP address to be on the same IP subnet.

This document provides a step-by-step procedure to set up an existing Db2 HADR configuration with Pacemaker on Azure with virtual IP address routing and the Azure Load Balancer as prerequisite for the virtual IP address.

Objective

Below is a high-level overview of a 2-node Db2 HADR setup with virtual IP address providing access from clients.

Note:

For access to the Db2 HADR cluster from the internet or your company network, refer to the appropriate Azure documentation:

image-20210622225426-1


 

Environment

Refer to the following IBM Documentation page for a list of platforms supported by Pacemaker, the same restrictions apply here: Restrictions on Pacemaker - IBM Documentation
 

Steps

 Setup Steps:

1. Refer to the “Configuring a clustered environment using the Db2 cluster manager (db2cm) utility” page of the IBM Documentation to deploy the automated HADR solution: Configuring a clustered environment using the Db2 cluster manager (db2cm) utility - IBM Documentation

2. Decide on an IP address and interface:
Compile a list of all host names, including virtual host names, and update your DNS servers to enable proper IP address to host-name resolution. If a DNS server doesn't exist or you can't update and create DNS entries, you need to use the local host files of the individual virtual machines that are participating in this scenario. If you're using host files entries, make sure that the entries are applied to all virtual machines in the environment.

Note:
Floating IP is not supported on a NIC secondary IP configuration in load-balancing scenarios. For details see Azure Load Balancer limitations in the Azure Documentation.

3. Configure Azure Load Balancer
:
To enable the environment for using a virtual IP, you must create an Azure Load Balancer first.

To do so, we recommend that you create an Azure Standard Load Balancer SKU as described here: Quickstart: Create an internal load balancer - Azure portal - Azure Load Balancer | Microsoft Docs

Once the Load Balancer is created, perform the following steps to complete the configuration:

A. Create a front-end IP pool:

  • Go to https://portal.azure.com
  • In the Azure portal, click “Load balancers”, select the previously created Load Balancer.
  • Click at “frontend IP pool”, and then select “Add”.
  • Enter the name of the new front-end IP pool (for example, Db2-connection).
  • Set the Assignment to “Static” and enter the IP address for the Virtual-IP to be used.
  • Select "OK”.
  • After the new front-end IP pool is created, make a note on the value of the pool IP address as you need it later in the process.

B. Create a back-end pool:
  • In the Azure portal, click “Load balancers”, select the previously created Load Balancer.
  • Open the Azure Load Balancer, select “backend pools” and then click ”Add”.
  • Enter the name of the new back-end pool (for example, Db2-backend).
  • Select “Add” to add a virtual machine.
  • Select the availability set or the virtual machines hosting the primary and secondary IBM Db2 database from the available choices further down on the screen.
  • Click “OK”.

C. Create a health probe:
  • In the Azure portal, click “Load balancers”, select the previously created Load Balancer.
  • Open the Azure Load Balancer, select “health probes” and then click ”Add”.
  • Enter the name of the new health probe (for example, Db2-hp).
  • Select “TCP” as the protocol and port, for example “62500”. Keep the “Interval” value set to “5”and keep the “Unhealthy threshold” value set to “2”.
  • Click “OK”.
  Note: The health probe port must not be the same as the Db2 Database Manager Communication port.

D. Create the load-balancing rules:
  • In the Azure portal, click “Load balancers”, select the previously created Load Balancer.
  • Open the Azure Load Balancer, select “backend pools” and then click ”Add”.
  • In the Azure portal, open the Azure Load Balancer, select “Load balancing rules”, and then select “Add”.
  • Enter the name of the new Load Balancer rule (for example, Db2-lbr).
  • Select the front-end IP address, the back-end pool, and the health probe that you created earlier from the drop-down menus.
  • Keep the Protocol set to “TCP”, and enter port number of the Database Manager Communication port, for example "5912" in the field “Port”
  • Increase the “idle timeout” to 30 minutes by using the slider.
  • Set the “Floating IP” checkbox to “Enabled”.
  • Select “OK”.


4. Create the resources for the virtual IP and the Load Balancer:
The virtual IP address and the Load Balancer resources both needs to be created, and collocated with the primary database in the cluster and started before the database is activated. To do so, execute the following commands:

Before creating the resources, open the firewall for the health probe port on all servers in the cluster if the firewall is enabled.  

firewall-cmd --add-port=<port>/tcp --permanent

firewall-cmd --reload

The IP addresses for both Db2 Database Nodes and the Virtual IP address must belong to the same subnet.  Replace the value for <IPAddress> and <lbPort> with the appropriate value for your environment, based on the load balancer configuration. For the <lbPort> use the previously assigned health probe port that is different from the Db2 Database Manger Communication port. Also, choose a valid name for the Pacemaker primitive and replace the Db2 instance name “db2pa2” and the database Name “PA2” with the identifiers in your environment.

A. Create the virtual IP primitive on one of the nodes in the cluster.

/db2/db2pa2/sqllib/bin/db2cm -create -primaryVIP <IPAddress> -db PA2 -instance db2pa2 

As <IPAddress> use the IP address configured in the front-end IP pool in previous section.

For details, have a look at the IBM Documentation here: Configuring a clustered environment using the Db2 cluster manager (db2cm) utility - IBM Documentation

B. Create the Load Balancer primitive on one of the nodes in the cluster.

crm configure primitive db2_db2pa2_db2pa2_PA2-primary-lbl azure-lb port=<lbport> meta op start interval=0 op stop interval=0

C. Create the collocation and order constraints for the Load Balancer

crm configure colocation db2_db2pa2_db2pa2_PA2-primary-lbl-colocation inf: db2_db2pa2_db2pa2_PA2-primary-lbl:Started db2_db2pa2_db2pa2_PA2-clone:Master 

crm configure order order-rule-db2_db2pa2_db2pa2_PA2-then-primary-lbl  Mandatory: db2_db2pa2_db2pa2_PA2-clone:promote db2_db2pa2_db2pa2_PA2-primary-lbl:start 

D. Start the Load Balancer Resource

crm resource manage db2_db2pa2_db2pa2_PA2-primary-lbl 

crm resource start db2_db2pa2_db2pa2_PA2-primary-lbl 



Remove load balancer & virtual IP resources from the cluster

With the db2cm utility, you can add and remove resources in the cluster or remove the cluster completely. However, the db2cm utility removes only resources created by the db2cm utility. As the Azure Load Balancer is not created using db2cm, you must remove the Load Balancer manually if you want to operate the cluster without Azure virtual IP and Load balancer. You also must remove the Load Balancer manually prior deleting Db2 databases, the Db2 instance or the entire cluster.

To remove the Azure Load balancer resource, perform following steps:

crm resource unmanage db2_db2pa1_db2pa1_PA1-primary-lbl

crm configure delete db2_db2pa2_db2pa2_PA2-primary-lbl

crm resource refresh

To remove the VIP resource, issue the following command:

db2cm -delete -primaryVIP -db PA2 -instance db2pa2

After you deleted the virtual IP and Load balancer, you can delete resources created with the db2cm utility. E.g.

db2cm -delete -db PA2 -instance db2pa

If you permanently remove the virtual IP and Load Balancer from the cluster and you do not need the Load Balancer anymore, delete the Load Balancer in the Azure Portal as well.

For further information about maintaining a Db2 Cluster, please refer to: Maintaining a Pacemaker cluster domain - IBM Documentation

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PkmAAE","label":"High Availability"}],"ARM Case Number":"","Platform":[{"code":"PF016","label":"Linux"}],"Version":"11.5.6;and future releases"}]

Document Information

Modified date:
09 November 2022

UID

ibm16465989