Upgrading Db2 HADR databases with active reads on standby
You can upgrade the Db2 primary database instance while having read only access to the standby database instance with the HADR deployment by using the reads on standby feature.
Before you begin
- On the standby database instances, Exec into the Db2 engine pod and run the following command to stop the
governor:
sv stop governor - On the primary database instances, Exec into the Db2 engine pod and run the following command to stop the
governor:
sv stop governor
Procedure
- Set upgrade pending on the standby instance:
- Edit all the standby instances to add an annotation
trigger:
This annotation runs db2ckupgrade to enable setUpgradePending on standby.db2u.databases.ibm.com/db2ckupgrade_hadr: initialize - On your standby instance, the Db2CheckUpgradeHadrSuccess
parameter must be set to TRUE and the
Db2CheckUpgradeHadrFailure must be set to FALSE for a
successful upgrade. Run the following command to check the parameter options:
oc get db2u <standby instance> -o jsonpath="{.status.conditions[?(@.type=='Db2CheckUpgradeHadrSuccess')].status}" oc get db2u <standby instance> -o jsonpath="{.status.conditions[?(@.type=='Db2CheckUpgradeHadrFailure')].status}"
If the Db2CheckUpgradeHadrFailure parameter is set to TRUE, follow the steps: .Exec into the Db2 engine podand and check the logs in the ${SUPPORTDIR}/db2_upgrade_check.log file- If there are any issues in the log file, resolve them.
- Edit and revert to the previous version.
- Re-run from Step 1.
- Edit all the standby instances to add an annotation
trigger:
- Edit the custom resource (CR) for your primary database.
- From the table, locate the custom resource (CR) for your primary database that is linked to your Db2 deployment.
- In the column on the right, click the ... and select Edit Db2uCluster or Edit Db2uInstance.
- Update the version field under spec with the
target version number. Refer to the following example:
spec: version: "s12.1.<x>.<y>-cn<z>>"- <x> is the latest mod pack version number
- <y> is the latest fix pack number
- <z> is the latest layer enhance release number
Note: For more information about Db2 versions for different IBM® Software Hub platforms, see Db2 compatible versions for IBM Software Hub versions.When you apply this change, the db2ckupgrade command runs a Kubernetes job to check if your current instance has the required upgrade compatibility. If the db2ckupgrade command in the Kubernetes job is successful, it will run the upgrade on your primary instance. If the db2ckupgrade command returnsUpgradeCheckFailed, see Troubleshooting db2ckupgrade failure during the service instance upgrade to resolve the issue. When the upgrade is complete, your custom resource changes to aReadystate and displays the version number in the status.
- Exec
into the Db2 engine pod
as the db2inst1 user. Run the following command to update the primary database:
db2_update_upgrade --databasesRun the following command to run post upgrade operations on your primary instance:db2_update_upgrade --post-upgradeYou have now upgraded your primary instance and it is ready for use.Important: Your primary instance is ready for applications after the upgrade, but there is no protection against any outage until you upgrade the standby database and it returnsPEERstate. - Edit the custom resource (CR) for your standby database.
- From the table, locate the custom resource (CR) for your standby database that is linked to your Db2 deployment.
- In the column on the right, click the ... and select Edit Db2uCluster or Edit Db2uInstance.
- Update the version field under spec with the
target version number. Refer to the following example:
spec: version: "s12.1.<x>.<y>-cn<z>>"- <x> is the latest mod pack version number
- <y> is the latest fix pack number
- <z> is the latest layer enhance release number
Readystate and displays the version number in the status.
- Exec into the Db2 engine
pod as the
db2inst1 user and run the following command to update the databases on your
standby instance.
db2_update_upgrade --databases - Monitor the upgrade progress to ensure primary and standby instances in your HADR
deployment are in
PEERstate. Exec into the Db2 engine pod on your primary instance and run the following command.manage_hadr -status - Exec into the Db2 engine
pod as the
db2inst1 user and run the following command to run post upgrade operations on
your standby instance after your HADR deployment is in a
PEERstate.db2_update_upgrade --post-upgrade