Example: Setting up Db2 HADR in a single OpenShift project
This example has one primary, one principal standby, and one auxiliary standby database, all located in the same OpenShift project.
Because the services were created by using Setting up the HADR configuration for Db2, the ports for each database are:
- Primary: 60006
- Standby: 60007
- Aux1: 60008
- Run the following command to invoke the
setup_config_hadr
script on the primary database Db2® pod:oc exec -it c-db2oltp-primary-db2u-0 -- setup_config_hadr --db-role primary --primary-name db2oltp-primary --standby-name db2oltp-standby --primary-port 60006 --standby-port 60007 --aux1-name db2oltp-aux --aux1-port 60008 --etcd-host my-etcd-client.my-etcd --etcd-port 2379
The output of the command contains the HADR configuration settings:
################################################################################ ### Creating HADR configuration file for HADR setup. ### ################################################################################ Database role -- primary primary database formation_id -- db2oltp-primary HADR_REMOTE_INST db2inst1 HADR_TIMEOUT 120 HADR_SYNCMODE NEARSYNC HADR_PEER_WINDOW 120 LOGINDEXBUILD ON HADR_LOCAL_HOST c-db2oltp-primary-db2u-0|c-db2oltp-primary-hadr-svc HADR_LOCAL_SVC 60006|60006 HADR_REMOTE_HOST c-db2oltp-standby-hadr-svc HADR_REMOTE_SVC 60007 HADR_TARGET_LIST c-db2oltp-standby-hadr-svc:60007|c-db2oltp-aux-hadr-svc:60008 etcd: my-etcd-client.my-etcd:2379
If the setup is successful, the following message displays at the end of the script output:
################################################################################ ### The HADR setup command completed the primary node setup. ### ################################################################################
- Copy the database backup image and keystore file in the backup storage area
(/mnt/backup/) from the primary database to the standby databases by using
rsync.
# Copy from primary database to a directory on the host called /tmp/hadr oc rsync c-db2oltp-primary-db2u-0:/mnt/backup/ /tmp/hadr # Copy from the /tmp/hadr directory on the host to the standby databases oc rsync /tmp/hadr/ c-db2oltp-standby-db2u-0:/mnt/backup/ oc rsync /tmp/hadr/ c-db2oltp-aux-db2u-0:/mnt/backup/
- Run the following command to invoke the
setup_config_hadr
script on the principal standby database Db2 pod:oc exec -it c-db2oltp-standby-db2u-0 -- setup_config_hadr --db-role standby --primary-name db2oltp-primary --standby-name db2oltp-standby --primary-port 60006 --standby-port 60007 --aux1-name db2oltp-aux --aux1-port 60008 --etcd-host my-etcd-client.my-etcd --etcd-port 2379
The output of the command:
################################################################################ ### Creating HADR configuration file for HADR setup. ### ################################################################################ Database role -- standby primary database formation_id -- db2oltp-standby HADR_REMOTE_INST db2inst1 HADR_TIMEOUT 120 HADR_SYNCMODE NEARSYNC HADR_PEER_WINDOW 120 LOGINDEXBUILD ON HADR_LOCAL_HOST c-db2oltp-standby-db2u-0|c-db2oltp-standby-hadr-svc HADR_LOCAL_SVC 60007|60007 HADR_REMOTE_HOST c-db2oltp-primary-hadr-svc HADR_REMOTE_SVC 60006 HADR_TARGET_LIST c-db2oltp-primary-hadr-svc:60006|c-db2oltp-aux-hadr-svc:60008 etcd: my-etcd-client.my-etcd:2379
- Run the following command to invoke the
setup_config_hadr
script on the auxiliary standby database Db2 pod:oc exec -it c-db2oltp-aux-db2u-0 -- setup_config_hadr --db-role aux1 --primary-name db2oltp-primary --standby-name db2oltp-standby --primary-port 60006 --standby-port 60007 --aux1-name db2oltp-aux --aux1-port 60008 --etcd-host my-etcd-client.my-etcd --etcd-port 2379
The output of the command:
################################################################################ ### Creating HADR configuration file for HADR setup. ### ################################################################################ Database role -- aux1 aux1 database formation_id -- db2oltp-aux HADR_REMOTE_INST db2inst1 HADR_TIMEOUT 120 HADR_SYNCMODE SUPERASYNC HADR_PEER_WINDOW 120 LOGINDEXBUILD ON HADR_LOCAL_HOST c-db2oltp-aux-db2u-0|c-db2oltp-aux-hadr-svc HADR_LOCAL_SVC 60008|60008 HADR_REMOTE_HOST c-db2oltp-primary-hadr-svc HADR_REMOTE_SVC 60006 HADR_TARGET_LIST c-db2oltp-standby-hadr-svc:60007|c-db2oltp-primary-hadr-svc:60006 etcd: my-etcd-client.my-etcd:2379