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

Procedure

  1. Set upgrade pending on the standby instance:
    1. Edit all the standby instances to add an annotation trigger:
      db2u.databases.ibm.com/db2ckupgrade_hadr: initialize
      This annotation runs db2ckupgrade to enable setUpgradePending on standby.
    2. 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: .
    1. Exec into the Db2 engine pod and and check the logs in the ${SUPPORTDIR}/db2_upgrade_check.log file
    2. If there are any issues in the log file, resolve them.
    3. Edit and revert to the previous version.
    4. Re-run from Step 1.
  2. Edit the custom resource (CR) for your primary database.
    1. From the table, locate the custom resource (CR) for your primary database that is linked to your Db2 deployment.
    2. In the column on the right, click the ... and select Edit Db2uCluster or Edit Db2uInstance.
    3. 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 returns UpgradeCheckFailed, see Troubleshooting db2ckupgrade failure during the service instance upgrade to resolve the issue. When the upgrade is complete, your custom resource changes to a Ready state and displays the version number in the status.
  3. Exec into the Db2 engine pod as the db2inst1 user.
    Run the following command to update the primary database:
    db2_update_upgrade --databases
    Run the following command to run post upgrade operations on your primary instance:
    db2_update_upgrade --post-upgrade
    You 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 returns PEER state.
  4. Edit the custom resource (CR) for your standby database.
    1. From the table, locate the custom resource (CR) for your standby database that is linked to your Db2 deployment.
    2. In the column on the right, click the ... and select Edit Db2uCluster or Edit Db2uInstance.
    3. 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
      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. When the upgrade is complete, your custom resource changes to a Ready state and displays the version number in the status.
  5. 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
  6. Monitor the upgrade progress to ensure primary and standby instances in your HADR deployment are in PEER state. Exec into the Db2 engine pod on your primary instance and run the following command.
    manage_hadr -status
  7. 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 PEER state.
    db2_update_upgrade --post-upgrade