Configuring the HADR API for the Db2 service
You can set up a Db2 high availability disaster recovery (HADR) configuration between databases that are on the same cluster and in the same Red Hat® OpenShift® project.
Before you begin
- Ensure you have the etcd endpoint (IP/name and port) available for HADR setup. See step 5 of Setting up an etcd store for HADR in Db2.
- Part of the setup process involves sharing the database backup image and keystore tar file between the primary and standby databases, as described in Step 5. You can perform this step either by creating a dynamically provisioned persistent volume or by using rsync to copy assets. If you are deploying Db2 for the purpose of using HADR, it can be beneficial to use a volume that is shared between the primary and standby databases. In this case, you need to create the volume when you deploy Db2. If you are setting up HADR on existing databases, using rsync might be preferable.
- Preserve your existing backup images. Important: When you start an HADR configuration, the backup images that are in the
${BACKUPDIR}
path are deleted. To preserve the existing backup images, move the images to a subdirectory under${BACKUPDIR}
. For example,${BACKUPDIR}/backup_001
.
About this task
After both Db2 services are deployed, follow these steps to set up the HADR configuration by using the Db2 HADR API, which is implemented by using an OpenShift custom resource definition (CRD).
Notes:
- This procedure can only be used for two deployments that are in the same OpenShift project in the same cluster.
- This method cannot be used for deployments on IBM® Cloud. To configure HADR, use the HADR scripts instead.
Procedure
Results
When the CRD status phase shows as Completed
, the HADR setup is complete,
automatic client reroute is enabled, and HADR is started.
You can periodically issue the oc get db2uhadr command to monitor the status. The following examples show the command results, and then the CRD status when HADR setup is complete:
NAME HADR PRIMARY HADR STANDBY STATE AGE
db2u-oltp-hadr db2u-oltp-1 db2u-oltp-1 Complete 7m8s
status:
conditions:
- lastTransitionTime: "2020-11-12T20:10:47Z"
message: Creating Db2u HADR configuration file on Standby
status: "False"
type: Creating Db2u HADR configuration files
- lastTransitionTime: "2020-11-12T20:12:54Z"
message: Done
status: "True"
type: Enabling ACR feature for HADR
- lastTransitionTime: "2020-11-12T20:12:56Z"
message: Done
status: "True"
type: Setting up Db2u HADR completed
- lastTransitionTime: "2020-11-12T20:11:33Z"
message: Done
status: "True"
type: Setting up Primary database copy for HADR
- lastTransitionTime: "2020-11-12T20:12:10Z"
message: Done
status: "True"
type: Setting up Standby database copy for HADR
- lastTransitionTime: "2020-11-12T20:12:46Z"
message: Done
status: "True"
type: Starting HADR on the Primary database copy
- lastTransitionTime: "2020-11-12T20:10:45Z"
message: Setting up Db2u HADR completed
status: "False"
type: latestPhase
hadrSettings: