You can enable Q Replication by editing the custom resource for the service and setting
configuration parameters.
Before you begin
Determine if your environment is compatible with Q Replication. For
more information, see System requirements.
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
-
Edit your Db2uCluster (for IBM Software Hub Versions prior to
5.2.0) or Db2uInstance custom resource (CR) to enable Q Replication and accept the 90-day trial
license.
-
Edit your Db2uCluster or Db2uInstance custom resource by running the following command:
oc edit db2ucluster deployment-ID
oc edit db2uinstance deployment-ID
-
Set the following properties in the
addOns.qrep section of the Db2uCluster or
Db2uInstance CR:
For Db2uCluster CR type:
addOns:
qrep:
enabled: true
infraHost: db2-cluster-hostname
infraIP: db2-cluster-external-ip
license:
accept: true
For Db2uInstance CR type:
addOns:
qrep:
enabled: true
infraHost: db2-instance-hostname
infraIP: db2-instance-external-ip
license:
accept: true
Where db2-cluster-hostname or db2-instance-hostnameis the
host name of the management node of the OpenShift®
cluster, and db2-cluster-external-ip or
db2-instance-external-ip is the external IP address of the management node.
-
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
-
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.
-
Run the qrep-expose-nodeports.sh script to expose the Db2 and replication service ports. Follow these
steps:
-
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
-
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
-
Change the permissions of the copied file:
chmod +x qrep-expose-nodeports.sh
-
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.