Creating separate storage for archive logs in Db2 Warehouse

You can create a persistent volume to separate the archive logs from the database file system.

About this task

By default, the archive logs of the database are stored on the same file system as the database. As a result, the file system might run out of space as the database and archive logs continue to grow.

To separate the archive logs from the database file system, create a persistent volume by completing the steps for an existing deployment.

Procedure

Follow one of these procedures depending on whether you are creating log storage for a new deployment or an existing deployment:
  • New deployment
    When you deploy the Db2 Warehouse service, on the Archive logs storage page of the web console, specify the following values:
    • Create new storage
    • Use storage template
    • Storage class: Choose manage-nfs-storage, ocs-storagecluster-ceph-rbd, or portworx-db2-rwo-sc.
    • Size: Your chosen value between 1 and 1,000 GiB.
  • Existing deployment
    1. Exec into the Db2 Warehouse pod with catalog partition.
    2. Run the following command:
      wvcli system disable
    3. Make a copy of the Db2 Warehouse StatefulSet by running the following commands:
      oc get sts c-<db2_instance_id-db2u> -o yaml > c-<db2_instance_id>-db2u.sts.bak
      cp c-<db2_instance_id>-db2u.sts.bak c-<db2_instance_id>-db2u.sts
      You can find the correct StatefulSet (sts) in the project by running the following command:
      oc get sts | grep <db2_instance_id>
      where <db2_instance_id> is the name of your deployment, which you can determine by running the following command:
      oc get db2ucluster
    4. Edit the c-<db2_instance_id>-db2u.sts file by adding two new sections, volumeMounts and volumeClaimTemplates. Replace size and storageclass_name with appropriate values.
      volumeMounts:
       - mountPath: /mnt/logs/archive
         name: archivelogs
      
      volumeClaimTemplates:
      - apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: archivelogs
        spec:
          accessModes:
          - ReadWriteOnce
          resources:
            requests:
              storage: <size>
          storageClassName: <storageclass_name>
          volumeMode: Filesystem
    5. Delete the Db2 Warehouse StatefulSet and recreate it with the updated c-<db2_instance_id>-db2u.sts file. Then, delete the Db2U pods so that they recycle and inherit the new StatefulSet definition.
      oc delete sts c-<db2_instance_id>-db2u --cascade=false
      oc create -f c-<db2_instance_id>-db2u.sts
      Delete all of the Db2 pods. The following example command only includes Db2 pod with suffix -0:
      oc delete pod c-<db2_instance_id>-db2u-0
    6. Edit the ConfigMap c-<db2_instance>-db2dbconfig. Change LOGARCHMETH1 DISK:/mnt/bludata0/db2/archive_log to LOGARCHMETH1 DISK:/mnt/logs/archive.
    7. When the db2u-0 pod and all other db2u pods are in 1/1 ready state, run the exec command on the Db2 Warehouse pod, and then run the following commands:
      chown -R db2inst1:db2iadm1 /mnt/logs/archive/
      su - db2inst1 -c "/db2u/scripts/apply-db2cfg-settings.sh"
      When you query LOGARCHMETH1,
      db2 get db cfg | grep -i logarchmeth1
      you will see that it is using your new persistent volume mount:
       First log archive method                 (LOGARCHMETH1) = DISK:/mnt/logs/archive/