Configuring storage for comparable performance with Db2 on-premises

You can deploy Db2® to use a local volume for its user data to achieve performance on Cloud Pak for Data that is comparable with Db2 on-premises.

About this task

By default, the Db2 transaction log and database partition path are saved under the user storage location, which might use OpenShift® Data Foundation, Portworx, or some other storage technology where network latency can slow performance, especially for large-volume workloads such as those incurred during loading operations.

In order to achieve performance that is similar to an on-premises deployment, follow these steps to deploy Db2 by using a local volume for its user data (the main database data).

Note: Local volumes are subject to the availability of the underlying node. If the node that is hosting the volume goes down, application downtime will result until the node comes back online.

Procedure

  1. On your OpenShift cluster, taint and label a node that uses a local disk. You will deploy Db2 on this node.
  2. If you are using hostPath, run the following OpenShift command to add a cluster-role policy for the zen-databases-sa service account to allow use of local persistent volumes:
    oc adm policy add-cluster-role-to-user system:controller:persistent-volume-binder system:serviceaccount:project:zen-databases-sa

    Where project is the OpenShift project for the zen-database-sa service account.

  3. Create the local storage path and label it for SELinux on the node where you will deploy Db2.
  4. In the Cloud Pak for Data web console, when deploying Db2 click Deploy database on dedicated nodes and enter the node label from Step 1 in the Value for node label box.
  5. In the console storage area, use one of the following options to specify a local volume for user storage:
    Option Steps
    Local persistent volume storage class

    In the web console, specify User storage > Create new storage > User storage template > Storage class.

    For an example of a storage class that targets a defined local volume, see Persistent storage using local volumes in the OpenShift documentation.

    The associated storageClassName is created and can be specified as the storage class to target your local volumes. Whether you choose to use a disk directly, or create logical volumes, the settings volumeMode: Filesystem and accessModes: ReadWriteOnce are required.

    This option is most likely the easiest to manage.

    Self-created PVC

    Specify User storage > Use existing claim.

    With this option, you must ensure that the PVC targets the local storage path on the node. Some examples of the existing claim are a PVC of type hostPath, or an NFS PVC that points to the dedicated node with a hostPath.

    You can also create a LocalVolume PVC. When using local volumes, you can install the Local Storage Operator to help you create the PVs in your definition.

    hostPath Specify User storage > Create new storage > Storage volume type > hostPath

    This option creates a hostPath persistent volume claim (PVC) that uses the host path that you specify as a persistent volume.

    NFS Specify User storage > Create new storage > Storage volume type > NFS

    This option creates an NFS PVC that uses the NFS server IP address (specify the same address as the dedicated node). For NFS server path, specify the host path.

  6. Optional: You can also use logical volume management (LVM) devices or a volume group (VG) to improve local storage performance. The following example includes the necessary steps:
    # Commands to run on corresponding dedicated worker nodes. In this example we will be referencing two local disks to create a Volume Group and Logical Volume  
    LOCAL_DISK_DEVICE_1=""
    LOCAL_DISK_DEVICE_2=""
    LOCAL_DISK_1="/dev/${LOCAL_DISK_DEVICE_1}"
    LOCAL_DISK_2="/dev/${LOCAL_DISK_DEVICE_2}"
    
    VG=db2u_vg
    LV1="db2u_lv_1"
    # Please specify the unit for the lvm size we will be creating. For example, specifying a 100 Gigabyte requires LV_SIZE="100G"
    LV_SIZE=""
    
     # Clean the drive or device
    sudo dd if=/dev/zero of=/dev/${LOCAL_DISK_DEVICE_1} bs=1M count=2 
    sudo dd if=/dev/zero of=/dev/${LOCAL_DISK_DEVICE_2} bs=1M count=2
    # Initialize the physical volumes for later use by the Logical Volume Manager 
    pvcreate ${LOCAL_DISK_1} 
    pvcreate ${LOCAL_DISK_2}
    # Create volume group from one or more physical volumes
    vgcreate ${VG} ${LOCAL_DISK_1} ${LOCAL_DISK_2} 
    # Create a logical volume in an existing volume group 
    lvcreate --name ${LV1} -L ${LV_SIZE} ${VG}
    
    # The device path we want to reference in this example for referencing this lvm we created would be:
    devicePaths:
      - /dev/db2u_vg/db2u_lv_1
    
    # Display information about logical volumes, volume groups, and physical volumes
    lvm lvs
    vgdisplay db2u_vg
    pvdisplay