Enabling Q Replication for Db2

You can enable Q Replication by editing the custom resource for the service and setting configuration parameters.

Before you begin

Ensure that you meet the minimum hardware, software, and storage requirements before you enable replication on your Db2 on cluster.

About this task

You must enable replication on both the source and target databases. When you enable replication, the Db2 operator deploys replication as an add-on component with its own pod, container, and services. Some Db2 registry variables and configuration parameters that support replication are also set.

Procedure

  1. Edit your custom resource (CR) to enable Q Replication and accept the 90-day trial license.
    1. Edit your custom resource by running the following command:
      oc edit db2ucluster deployment-ID
    2. Set the following properties in the addOns.qrep section of the CR:
      addOns:
          qrep:
            enabled: true
            infraHost: db2-cluster-hostname
            infraIP: db2-cluster-external-ip
            license:
              accept: true

      Where db2-cluster-hostname is the host name of the management node of the OpenShift® cluster, and db2-cluster-external-ip is the external IP address of the management node.

    3. In the storage section of the CR, specify qrepdata for the storage name and the storageClassname that contains the preferred storage class type as saved on your system. qrepdata supports Network File System (NFS), Container Storage (OCS), and IBM Spectrum Scale storage classes.
      storage:
      - name: qrepdata
        spec:
          accessModes:
          - ReadWriteMany
          resources:
            requests:
              storage: 100Gi
          storageClassName: <storage_class_name>
        type: create
      Note: Select the appropriate storage class defined in your local environment for the Db2 deployment on which you are enabling Q Replication.

      When you save and close the CR, the operator deploys the replication component. The following Db2 database configuration parameters are set to enable replication:

      DFT_SCHEMAS_DCC=YES
      LOG_DDL_STMTS=YES
      LOG_APPL_INFO=YES
      EXTBL_LOCATION=/mnt/blumeta0/home;/mnt/bludata0/scratch;/mnt/external;/mnt/qrepdata/applyetfiles/repl

      The following registry variables are set:

      DB2_DCC_BINARY_FILE=true
      DB2_DCC_FILE_DEL_THRES=1
      DB2_DCC_FILE_INS_THRES=10
      DB2_DCC_FILE_CHUNKSZ=100000000
      DB2_DCC_FILE_PATH=/mnt/qrepdata/db2supplog/db2
      DB2_CDE_DCC=true
      DB2_FMP_RUN_AS_CONNECTED_USER=NO
  2. Run the following commands to check the status of the replication deployment:
    oc get deployment | grep qrep
    oc get pod | grep qrep

    Use the Db2 instance ID to find a matching replication deployment and pod name. Verify that the Db2 cluster is in Ready state and that the replication add-on is in Running state.

  3. Run the qrep-expose-nodeports.sh script to expose the Db2 and replication service ports. Follow these steps:
    1. Find the Db2 pod prefix where the replication pod is deployed:
      oc get po | grep db2
      In the following output, the replication pod is c-db2oltp-1636513131239517-qrep-7c7847968c-7pjs2 and the prefix is c-db2oltp-1636513131239517.
      c-db2oltp-1636513131239517-db2u-0                  1/1     Running           0          11m
      c-db2oltp-1636513131239517-etcd-0                  1/1     Running           0          11m
      c-db2oltp-1636513131239517-qrep-7c7847968c-7pjs2   1/1     Running           0          11m
      
    2. Copy the script from the replication container to the infra node of the OpenShift cluster:
      oc cp repl_container_pod_name:/opt/ibm/bludr/scripts/bin/qrep-expose-nodeports.sh qrep-expose-nodeports.sh
    3. Change the permissions of the copied file:
      chmod +x qrep-expose-nodeports.sh
    4. Run the script for each replication container:
      ./qrep-expose-nodeports.sh db2u_cluster_instance_prefix

      From the example in Step 3.a, db2u_cluster_instance_prefix is c-db2oltp1636513131239517.

What to do next

To plan for your data replication, see Planning for data Q Replication.

For more information on setting up and managing replication, see Administering Q Replication.