Upgrading Db2 from Version 3.5 to Version 4.6

A project administrator can upgrade Db2 from Cloud Pak for Data Version 3.5 to Version 4.6.0, 4.6.1, or 4.6.2.

Important: To complete this task, you must be running Db2 Version 11.5.5.0-cn3 or later.
Supported upgrade paths
If you are running 11.5.5.0-cn3 or later, you can upgrade to Versions 4.6.0 - 4.6.2.
Unsupported upgrade paths
You cannot upgrade from Version 3.5 to Version 4.6.3 or later. You must upgrade to 4.6.2 before you upgrade to 4.6.3 or later.
What permissions do you need to complete this task?
The permissions that you need depend on which tasks you must complete:
  • To create the Db2 operators, you must have the appropriate permissions to create operators and you must be an administrator of the project where the Cloud Pak for Data operators are installed. This project is identified by the ${PROJECT_CPD_OPS} environment variable.
  • To upgrade Db2, you must be an administrator of the project where Db2 is installed. This project is identified by the ${PROJECT_CPD_INSTANCE} environment variable.
When do you need to complete this task?
If you didn't upgrade Db2 when you upgraded the platform, you can complete this task to upgrade your existing Db2 installation.

If you want to upgrade all of the Cloud Pak for Data components at the same time, follow the process in Upgrading the platform and services instead.

Important: All of the Cloud Pak for Data components in a deployment must be installed at the same release.

Information you need to complete this task

Review the following information before you upgrade Db2:

Environment variables
The commands in this task use environment variables so that you can run the commands exactly as written.
  • If you don't have the script that defines the environment variables, see Setting up installation environment variables.
  • To use the environment variables from the script, you must source the environment variables before you run the commands in this task, for example:
    source ./cpd_vars.sh
Security context constraint requirements
Db2 uses a custom security context constraint (SCC). For details, see Creating the custom SCC for Db2.
Installation location
Db2 is installed in the same project (namespace) as the Cloud Pak for Data control plane. This project is identified by the ${PROJECT_CPD_INSTANCE} environment variable.
Storage requirements
You don't need to specify storage when you upgrade Db2.

Before you begin

This task assumes that the following prerequisites are met:

Prerequisite Where to find more information
The cluster meets the minimum requirements for Db2. If this task is not complete, see System requirements.
The workstation from which you will run the upgrade is set up as a client workstation and includes the following command-line interfaces:
  • Cloud Pak for Data CLI: cpd-cli
  • OpenShift® CLI: oc
If this task is not complete, see Setting up a client workstation.
The Cloud Pak for Data control plane is upgraded. If this task is not complete, see Upgrading the platform and services.
For environments that use a private container registry, such as air-gapped environments, the Db2 software images are mirrored to the private container registry. If this task is not complete, see Mirroring images to a private container registry.
The custom security context constraint (SCC) required to run Db2 exists. If this task is not complete, see Creating the custom SCC for Db2.

Procedure

Complete the following tasks to upgrade Db2:

  1. Logging in to the cluster
  2. Installing the operator
  3. Upgrading the service
  4. Validating the upgrade
  5. Adding required volume source
  6. Upgrading each Db2 database deployment
  7. Verifying the deployment upgrade
  8. Adding a label to the Db2 cluster for backup and restore operations
  9. What to do next

Logging in to the cluster

To run cpd-cli manage commands, you must log in to the cluster.

To log in to the cluster:

  1. Run the cpd-cli manage login-to-ocp command to log in to the cluster as a user with sufficient permissions to complete this task. For example:
    cpd-cli manage login-to-ocp \
    --username=${OCP_USERNAME} \
    --password=${OCP_PASSWORD} \
    --server=${OCP_URL}
    Tip: The login-to-ocp command takes the same input as the oc login command. Run oc login --help for details.

Installing the operator

The Db2 operator simplifies the process of managing the Db2 service on Red Hat® OpenShift Container Platform.

To upgrade Db2, you must install the Db2 operator and create the Operator Lifecycle Manager (OLM) objects, such as the catalog source and subscription, for the operator.

Who needs to complete this task?
You must be a cluster administrator (or a user with the appropriate permissions to install operators) to create the OLM objects.
When do you need to complete this task?
Complete this task if the Db2 operator and other OLM artifacts have not been created for the current release.

It is not necessary to run this command multiple times for each service that you plan to upgrade. If you complete this task and the OLM artifacts already exist on the cluster, the cpd-cli will recreate the OLM objects for all of the existing components in the ${PROJECT_CPD_OPS} project.

To install the operator:

  1. Create the OLM objects for Db2:
    cpd-cli manage apply-olm \
    --release=${VERSION} \
    --cpd_operator_ns=${PROJECT_CPD_OPS} \
    --components=db2oltp
    • If the command succeeds, it returns [SUCCESS]... The apply-olm command ran successfully.
    • If the command fails, it returns [ERROR] and includes information about the cause of the failure.

What to do next: Upgrade the Db2 service.

Upgrading the service

After the Db2 operator is installed, you can upgrade Db2.

Who needs to complete this task?
You must be an administrator of the project where Db2 is installed.
When do you need to complete this task?
Complete this task for each instance of Db2 that is associated with an instance of Cloud Pak for Data Version 4.6.

To upgrade the service:

  1. Create the custom resource for Db2.
    cpd-cli manage apply-cr \
    --components=db2oltp \
    --release=${VERSION} \
    --cpd_instance_ns=${PROJECT_CPD_INSTANCE} \
    --license_acceptance=true

Validating the upgrade

Db2 is upgraded when the apply-cr command returns [SUCCESS]... The apply-cr command ran successfully.

However, you can optionally run the cpd-cli manage get-cr-status command if you want to confirm that the custom resource status is Completed:

cpd-cli manage get-cr-status \
--cpd_instance_ns=${PROJECT_CPD_INSTANCE} \
--components=db2oltp

Adding required volume source

Before you start the upgrade procedure, you also need to add the required volume source by running the oc patch command for each Db2 deployment that you plan to upgrade:

oc patch db2uclusters instance_id --type=merge -p '{ "spec": { "advOpts": { "volumeSources": [{ "visibility": [ "db2u" ], "volumeSource": { "secret": { "secretName": "zen-service-broker-secret"}}}]}}}' 

Replace instance_id with the deployment identifier that is shown in the web console for the Db2 deployment.

Run the following command and wait for the status to change to Ready:

oc get db2ucluster instance_id -o jsonpath='{.status.state} {"\n"}'

Upgrading each Db2 database deployment

Important: If you have configured HADR on your Db2 deployments, do not proceed. Instead, see Upgrading Db2 deployments with an HADR configuration.
  1. Log in to Red Hat OpenShift Container Platform as a user with sufficient permissions to complete the task:
    oc login OpenShift_URL:port
  2. For each Db2 database deployment, follow these steps to check the Db2 version:
    1. Run the following command to find the instance identifier (the result will be under "NAME"):
      oc get Db2uCluster
    2. Run the following command, substituting the instance identifier, to get the version:
      oc get db2ucluster instance_id -o yaml | grep version

    See Db2 versions for different Cloud Pak for Data versions for more information.

  3. Run the following oc patch command to upgrade the Db2 database deployment:
    oc patch db2ucluster db2oltp-<instanceID> --type merge -p '{"spec":{"version":"<databaseVersion>","environment":{"database":{"ssl":{"certLabel":"CN=zen-ca-cert", "secretName":"db2oltp-internal-tls"}}}}}'
    • Replace <instanceID> with the instance identifier of your database, obtained from the oc get Db2uCluster command.
    • Replace <databaseVersion> with your database version.
    Note: The SSL certificate has a 1 year expiry.

Verifying the deployment upgrade

You can use a command or the web console to verify that the deployment was upgraded and is ready to use.

Command
Run the following command and wait for the status to change to Ready:
oc get db2ucluster instance_id -o jsonpath='{.status.state} {"\n"}'
Web console
From the database details page, wait for the database version to change.

During the upgrade process from 3.5.x to 4.5.0 by using cpd-cli, you might encounter missing permissions or version errors. For more information, see Db2u-operator pod errors when you upgrade from 3.5.x to 4.5.x or from 4.0.x to 4.5.x (specialized) in Db2.

Adding a label to the Db2 cluster for backup and restore operations

After you upgrade to Cloud Pak for Data 4.5.x, you must label your Db2 clusters so that the Cloud Pak for Data backup and restore utilities can operate with changes to the Db2 backup and restore configmap. Follow these steps:

  1. Retrieve the name of the Cloud Pak for Data installation's Db2 clusters:
    oc get db2ucluster -A -ojsonpath='{.items[?(@.spec.environment.dbType=="db2oltp")].metadata.name}'
  2. For each, export the Db2 cluster name and label the cluster:
    export DB2UCLUSTER=db2-cluster_name
    oc label db2ucluster ${DB2UCLUSTER} db2u/cpdbr=db2u --overwrite
  3. Verify that the Db2 cluster now contains the new label:
    oc get db2ucluster ${DB2UCLUSTER} --show-labels
  4. Retrieve the names of the Db2U StatefulSets:
    oc get sts -n ${PROJECT_CPD_INSTANCE} -l app=$DB2UCLUSTER
  5. For each StatefulSet, export the sts name label it:
    export DB2USTS=db2-sts-name
    oc label sts  ${DB2USTS} -n ${PROJECT_CPD_INSTANCE} db2u/cpdbr=db2u --overwrite
  6. Label the pod template for all StatefulSets that contain the suffix -db2u:
    oc patch sts  ${DB2USTS} -n ${PROJECT_CPD_INSTANCE}  --type merge --patch '{"spec": {"template": {"metadata": {"labels": {"db2u/cpdbr": "db2u"}}}}}'

What to do next

  1. Remove the 3.5 version of the Db2 service. See Removing older Db2 versions after upgrading for details.
  2. Review the tasks in Post-installation setup for the Db2 service to determine whether any need to be completed before users can access the Db2 service.