To complete a rolling update on your Db2
Warehouse HADR database instance, edit
the source YAML of the custom resource (CR) that is associated with your Db2
Warehouse
service.
Before you begin
Note: This procedure also applies to Db2uInstance CR. To modify this procedure for use with
Db2uInstance CR, use db2uinstance in place of db2ucluster.
Note: Only SMP deployments on Db2
Warehouse can be configured to use
HADR.
- Upgrade the Db2
Warehouse service. For more information, see Upgrading Db2 Warehouse.
- Ensure your primary and principal standby databases are in
PEER state.
About this task
If you are upgrading to
Db2
Warehouse, there is an interruption when processing is
switched from one database to the other. The duration of the interruption depends on the time it
takes for automatic client reroute (ACR) to switch between the primary and standby
connection.
Note: This upgrade procedure keeps at least one HADR database available throughout the
upgrade process.
Procedure
-
Modify environment and version variables for your
deployments:
DB2UCLUSTER_PRIMARY="db2oltp-crd-hadr-primary"
DB2UCLUSTER_STANDBY="db2oltp-crd-hadr-standby"
PROJECT_PRIMARY="zen"
PROJECT_STANDBY="zen"
DB2_VERSION="s12.1.2.0"
Db2uCluster names can be obtained with the
oc get db2ucluster command, in the namespace where the deployments are located. The
DB2_VERSION is the version number to which you want to upgrade.
- Run the stop governor command on your deployments.
Note: Governor does not run
on auxiliary standbys. This step isn't necessary on auxiliary deployments.
Run the command on
your principal standby deployment first, then your primary
deployment:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- sv stop governor
oc exec -it c-${DB2UCLUSTER_PRIMARY}-db2u-0 -n ${PROJECT_PRIMARY} -- sv stop governor
- Upgrade your standby deployment.
- Patch the
Db2uCluster custom resource to the new
version: oc patch db2ucluster ${DB2UCLUSTER_STANDBY} -n ${PROJECT_STANDBY} --type merge -p "{\"spec\":{\"version\":\"${DB2_VERSION}\"}}"
The
Db2uCluster returns
READY when the standby
deployment upgrade is complete.
- Return the status:
oc get db2ucluster ${DB2UCLUSTER_STANDBY} -n ${PROJECT_STANDBY}
- If there are auxiliary deployments in the HADR topology, upgrade them one at a time.
Repeat this step and wait for each deployment to return a
READY
status.
- Switch roles for the standby database to set it as the new primary database:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- su - db2inst1
db2 takeover hadr on db ${DBNAME}
- Upgrade the new standby (former primary) deployment.
- Patch the
Db2uCluster custom resource to the new
version: oc patch db2ucluster ${DB2UCLUSTER_PRIMARY} -n ${PROJECT_PRIMARY} --type merge -p "{\"spec\":{\"version\":\"${DB2_VERSION}\"}}"
The
Db2uCluster returns
READY when the standby deployment upgrade is
complete.
- Return the status:
oc get db2ucluster ${DB2UCLUSTER_PRIMARY} -n ${PROJECT_PRIMARY}
- Update the databases.
- Update the databases on the current primary (former standby) deployment:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- bash
su - db2inst1 -s /bin/bash -lc 'db2_update_upgrade --databases --post-upgrade'
- Wait for the log replay to complete.
- Ensure that the HADR pair has reached
PEER state again by running the
following command and reviewing the status:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- manage_hadr -status
- Deactivate, then activate the database in the current standby (former primary) deployment
by running the following
commands:
oc exec -it c-${DB2UCLUSTER_PRIMARY}-db2u-0 -n ${PROJECT_PRIMARY} -- su - db2inst1
db2 deactivate db ${DBNAME}
db2 activate db ${DBNAME}
If
there are auxiliary deployments in the HADR topology, repeat this step to deactivate and activate
each deployment.
- Complete a role switch to revert back to the original primary deployment by running the
following command:
oc exec -it c-${DB2UCLUSTER_PRIMARY}-db2u-0 -n ${PROJECT_PRIMARY} -- su - db2inst1
db2 takeover hadr on db ${DBNAME}
- Deactivate, then activate the database in the standby deployment by running the following
command:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- su - db2inst1
db2 deactivate db ${DBNAME}
db2 activate db ${DBNAME}
- Start the governor on the primary deployment:
oc exec -it c-${DB2UCLUSTER_PRIMARY}-db2u-0 -n ${PROJECT_PRIMARY} -- su - db2inst1
${HOME}/governor/governor.sh start
- Start the governor on the standby deployment:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- su - db2inst1
${HOME}/governor/governor.sh start
Results
You have now upgraded your HADR Db2
Warehouse databases.