Upgrading Db2 Warehouse from Version 5.1.x to a later 5.1 refresh

An instance administrator can upgrade Db2 Warehouse from Version 5.1.x to a later 5.1 refresh.

Who needs to complete this task?

Instance administrator To upgrade Db2 Warehouse, you must be an instance administrator. An instance administrator has permission to manage software in the following projects:

The operators project for the instance

The operators for this instance of Db2 Warehouse are installed in the operators project. In the upgrade commands, the ${PROJECT_CPD_INST_OPERATORS} environment variable refers to the operators project.

The operands project for the instance

The custom resources for the control plane and Db2 Warehouse are installed in the operands project. In the upgrade commands, the ${PROJECT_CPD_INST_OPERANDS} environment variable refers to the operands project.

When do you need to complete this task?

Review the following options to determine whether you need to complete this task:

  • If you want to upgrade the IBM Software Hub control plane and one or more services at the same time, follow the process in Upgrading an instance of IBM Software Hub instead.
  • If you didn't upgrade Db2 Warehouse when you upgraded the IBM Software Hub control plane, complete this task to upgrade Db2 Warehouse.

    Repeat as needed If you are responsible for multiple instances of IBM Software Hub, you can repeat this task to upgrade more instances of Db2 Warehouse on the cluster.

Information you need to complete this task

Review the following information before you upgrade Db2 Warehouse:

Version requirements

All the components that are associated with an instance of IBM Software Hub must be installed at the same release. For example, if the IBM Software Hub control plane is at Version 5.1.3, you must upgrade Db2 Warehouse to Version 5.1.3.

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, run:
    source ./cpd_vars.sh

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 Warehouse. 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 the following command-line interfaces:
  • IBM Software Hub CLI: cpd-cli
  • OpenShift® CLI: oc
If this task is not complete, see Updating client workstations.
The IBM Software Hub control plane is upgraded. If this task is not complete, see Upgrading an instance of IBM Software Hub.
For environments that use a private container registry, such as air-gapped environments, the Db2 Warehouse software images are mirrored to the private container registry. If this task is not complete, see Mirroring images to a private container registry.
For environments that use a private container registry, such as air-gapped environments, the cpd-cli is configured to pull the olm-utils-v3 image from the private container registry. If this task is not complete, see Pulling the olm-utils-v3 image from the private container registry.
If you plan to use features that require Red Hat® OpenShift AI, Red Hat OpenShift AI is installed. If this task is not complete, see Installing Red Hat OpenShift AI.

Procedure

Complete the following tasks to upgrade Db2 Warehouse:

  1. Upgrading the service
  2. Validating the upgrade
  3. Upgrading existing service instances
  4. Verifying the service instance upgrade
  5. What to do next

Upgrading the service

Important: The Operator Lifecycle Manager (OLM) objects for Db2 Warehouse were updated when you upgraded the IBM Software Hub platform. The cpd-cli manage apply-olm updates all of the OLM objects in the operators project at the same time.

To upgrade Db2 Warehouse:

  1. Log the cpd-cli in to the Red Hat OpenShift Container Platform cluster:
    ${CPDM_OC_LOGIN}
    Remember: CPDM_OC_LOGIN is an alias for the cpd-cli manage login-to-ocp command.
  2. Update the custom resource for Db2 Warehouse.
    cpd-cli manage apply-cr \
    --components=db2wh \
    --release=${VERSION} \
    --cpd_instance_ns=${PROJECT_CPD_INST_OPERANDS} \
    --license_acceptance=true \
    --upgrade=true

Validating the upgrade

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

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

cpd-cli manage get-cr-status \
--cpd_instance_ns=${PROJECT_CPD_INST_OPERANDS} \
--components=db2wh

Upgrading existing service instances

After you upgrade Db2 Warehouse, you must upgrade any service instances that are associated with Db2 Warehouse.

Before you begin

Create a profile on the workstation from which you will upgrade the service instances.

The profile must be associated with a IBM Software Hub user who has either the following permissions:

  • Create service instances (can_provision)
  • Manage service instances (manage_service_instances)

For more information, see Creating a profile to use the cpd-cli management commands.

Remove custom patches and override scripts, if applicable:
  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. Run the following command to remove custom patches and override scripts:
    oc set volume statefulset/c-${DB2U_ID}-db2u -n ${PROJECT_CPD_INST_OPERANDS} --remove --name=<volume_name>
Procedure

To upgrade the service instances:

  1. Get the list of Db2 Warehouse service instances:
    cpd-cli service-instance list \
    --service-type=db2wh \
    --profile=${CPD_PROFILE_NAME}
  2. Set the INSTANCE_NAME environment variable to the name of the service instance that you want to upgrade:
    export INSTANCE_NAME=<instance-name>
  3. Run the following command to check whether your Db2 Warehouse service instances is in running state:
    cpd-cli service-instance status ${INSTANCE_NAME} \ 
    --profile=${CPD_PROFILE_NAME} \ 
    --service-type=db2wh

    If the service instance state returns as UNKNOWN or the provision status as FAILED, follow the steps in Troubleshooting Db2 Warehouse service instance status failures.

  4. Upgrade the service instance:
    cpd-cli service-instance upgrade \
    --service-type=db2wh \
    --instance-name=${INSTANCE_NAME} \
    --profile=${CPD_PROFILE_NAME}
  5. Verify that the service instance is upgraded and is ready to use.
  6. Repeat the preceding steps to upgrade each service instance associated with this instance of IBM Software Hub.

Verifying the service instance upgrade

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

Command
  1. Run the following command and wait for the status to change to Ready:
    oc get db2ucluster <instance_id> -o jsonpath='{.status.state} {"\n"}'
  2. Run the following command to check the status of your Db2 Warehouse service instance:
    cpd-cli service-instance status ${INSTANCE_NAME} \
    --profile=${CPD_PROFILE_NAME} \
    --service-type=db2wh
  3. Run the following command to check that the service instance has updated:
    cpd-cli service-instance list \
    --profile=${CPD_PROFILE_NAME} \
    --service-type=db2wh
  4. Go to updating the service instance configmap.
Web console
From the Database details page, wait for the database version to change.

Updating the service instance configmap

After upgrading, you need to update the configmap. Run the following commands to patch the instance.json configmap.
  1. Retrieve the values for CM_NAME, NAMESPACE, and NEW_VERSION variables by running the following command:
    cpd-cli service-instance list \
    --profile=${CPD_PROFILE_NAME}\
    --service-type=db2wh
    The sample output of the previous command is as follows:
    Namespace      Service type           Version                ID                           Name                  Provision status       Upgrade version option
    ---------     -------------       ---------------        ---------------         ------------------------      -------------------     -----------------------
    cpd-instance    db2wh           11.5.9.0-cn5-amd64      1689782702423826             Db2-Instance            UPGRADE_IN_PROGRESS              []                                          
  2. Set the values for the environment variables to run the bash script in step 3.
    1. Set the CM_NAME environment variable to the Db2u instance configmap name:
      CM_NAME=""  #The instance.json configmap name, example db2wh-1689782702423826-db2wh-cm
      CM_NAME is Db2u instance configmap name and is obtained like this: <service_type>-<instance_id>-<service_type>-cm, for example, db2wh-1689782702423826-db2wh-cm.
    2. Set the NAMESPACE environment variable:
      NAMESPACE="zen" #default is zen
      NAMESPACE is Cluster namespace where Db2 Warehouse instance and the configmap are installed, for example, cpd-instance.
    3. Set the NEW_VERSION environment variable:
      NEW_VERSION="" #addon_version, example: 11.5.9.0-cn5-amd64 
      NEW_VERSION is upgraded Db2 Warehouse instance version, for example, 11.5.9.0-cn5-amd64.
  3. Run the bash script after updating the environment variables.
    #!/bin/bash
    set -e
    
    CM_NAME=""
    NAMESPACE="zen"
    NEW_VERSION=""
    
    # Step 0: Get the backup of the configmap 
    oc get configmap "$CM_NAME" -n "$NAMESPACE" -oyaml > "$CM_NAME".yaml
    
    # Step 1: Get the current instance.json value
    raw_json=$(oc get configmap "$CM_NAME" -n "$NAMESPACE" -o jsonpath='{.data.instance\.json}')
    
    # Step 2: Update the addon_version, create_arguments.metadata.version and provision_status field using jq:
    updated_json=$(echo "$raw_json" | jq \
      --arg ver "$NEW_VERSION" \
      '.addon_version = $ver
       | .create_arguments.metadata.version = $ver
       | .provision_status = "UPGRADED"
       | .create_arguments.metadata["status-info"].status = "RUNNING"
       | .create_arguments.metadata.status = "RUNNING"')
    
    # Step 3: Format as pretty-printed multiline
    formatted_json=$(echo "$updated_json" | jq '.')
    
    escaped_json=""
    first_line=true
    while IFS= read -r line; do
      line=${line//\"/\\\"}  # escape quotes
      if [ "$first_line" = true ]; then
        escaped_json="$line"
        first_line=false
      else
        escaped_json="${escaped_json}\\n${line}"
      fi
    done <<< "$formatted_json"
    
    escaped_json="\"${escaped_json}\""
    
    # Step 4: Build patch payload
    patch_payload=$(cat <<EOF
    [
      {
        "op": "replace",
        "path": "/metadata/labels/icpdata_addon_version",
        "value": "$NEW_VERSION"
      },
      {
        "op": "replace",
        "path": "/data/instance.json",
        "value": $escaped_json
      }
    ]
    EOF
    )
    
    # Step 5: Apply the patch
    oc patch configmap "$CM_NAME" -n "$NAMESPACE" --type=json -p "$patch_payload"
    echo -e "\nPatch command executed for ConfigMap '${CM_NAME}' in namespace '${NAMESPACE}' with version '${NEW_VERSION}'."
    oc get cm -n ${NAMESPACE} ${CM_NAME} -o yaml
    Note: The script always creates a backup of the configmap before patching it. The copy of the configmap is saved to a YAML file with the same name as the configmap.

What to do next

Attention: If you have a Q Replication deployment, you need to exchange SSL certificates after upgrading. For more information, see Trusting targets and exchanging Db2 TLS certificates.

Review Post-installation setup for the Db2 Warehouse service to determine whether any tasks need to be completed before users can access the Db2 Warehouse service.