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 deploymentWhen 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
- Exec into the Db2 Warehouse pod with catalog partition.
- Run the following
command:
wvcli system disable
- 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
You can find the correct StatefulSet (cp c-<db2_instance_id>-db2u.sts.bak c-<db2_instance_id>-db2u.sts
sts
) in the project by running the following command:
where <db2_instance_id> is the name of your deployment, which you can determine by running the following command:oc get sts | grep <db2_instance_id>
oc get db2ucluster
- 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
- 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
Delete all of the Db2 pods. The following example command only includes Db2 pod with suffix -0:oc create -f c-<db2_instance_id>-db2u.sts
oc delete pod c-<db2_instance_id>-db2u-0
- Edit the ConfigMap c-<db2_instance>-db2dbconfig. Change
LOGARCHMETH1 DISK:/mnt/bludata0/db2/archive_log
toLOGARCHMETH1 DISK:/mnt/logs/archive
. - 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/
When you query LOGARCHMETH1,su - db2inst1 -c "/db2u/scripts/apply-db2cfg-settings.sh"
you will see that it is using your new persistent volume mount:db2 get db cfg | grep -i logarchmeth1
First log archive method (LOGARCHMETH1) = DISK:/mnt/logs/archive/