You can upgrade the Db2 server by editing the source YAML of the custom
resource (CR) that is associated with your Db2 on Red Hat
OpenShift cluster. When HADR is enabled, the upgrade steps vary depending on the Db2® on OpenShift release to which you are upgrading.
Before you begin
- Upgrade your Db2 Operator to the intended
version.
- The primary and principal standby databases must be in
PEER
state before you
start the upgrade.
- If you have created an external etcd store with etcd that is packaged with Db2 , see Upgrading the
external etcd store created with the Db2 etcd image for instructions on how to upgrade to the
latest image. These steps should be performed after the HADR rolling upgrade is complete, or between
steps 17 and 18 in the task procedure.
If you are upgrading to 11.5.7.0 or earlier versions, review the following
conditions:
- When upgrading to Db2 11.5.7.0 and earlier versions, you need to first stop
your HADR deployment, upgrade your Db2uCluster, and then
reconfigure your HADR deployment.
- Since the release of Db2 11.5.7.0-cn5, the Db2uCluster CR requires
NetworkPolicies that permit HADR communication between deployments. If you are
upgrading from Db2 11.5.7.0-cn4 or earlier, you need to manually create these
NetworkPolicies before upgrading your Db2uCluster instances. See Creating NetworkPolicies for your Db2 on OpenShift
HADR deployment upgrade.
About this task
If you are upgrading to the
Db2 on
OpenShift® 11.5.8 release (including CNs), there
is a slight interruption when processing is switched from one database to the other. The duration of
the interruption is the time it takes for ACR to switch between the primary and standby connection.
The length of this duration depends on how you have configured automatic client reroute (ACR).
Note: This upgrade procedure keeps at least one HADR database available throughout the
upgrade process. In previous upgrades to HADR deployments of Db2 on OpenShift 11.5.7, the databases were unavailable
during 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="s11.5.8.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. For more
information, see
Upgrading and updating your Db2 on Red Hat
OpenShift cluster.
- 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.
- Do a role switch to 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.
- Run the
db2u_update.sh
update script on the current primary (former
standby) deployment with the -db
parameter:
oc exec -it c-${DB2UCLUSTER_STANDBY}-db2u-0 -n ${PROJECT_STANDBY} -- bash
- For a deployment on a
DB2_VERSION
that is earlier than s11.5.9.0, run
this command:
su - db2inst1 -s /bin/bash -c '/db2u/scripts/db2u_update.sh -db'
- For a deployment on a
DB2_VERSION
that is s11.5.9.0 or later, run
this command:
su - db2inst1 -s /bin/bash -lc 'db2_update_upgrade --database'
- 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:
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.
- Perform 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
Your
HADR
Db2 on
OpenShift
deployment is now upgraded to the 11.5.9.0 release.