You can configure the replication functionality from Db2 Warehouse Common Container to
Db2 Warehouse on Red Hat Openshift and Kubernetes.
Before you begin
You must ensure that you are using the following versions:
- Db2 Warehouse common Container version 11.5.9-cn1 or later.
- Db2 Warehouse on Red Hat Openshift and Kubernetes version s11.5.9.0-cn3 or later.
- Cloud Pak for Data version 5.0.3 or later.
Important: When replicating from Db2 Warehouse Common container you can only
replicate data from one source site to one target site. Replicating to multiple or a different
target site is not supported. For example:
- Replication from a Source site A (Db2 Warehouse Common Container to Target B (Db2 on Red Hat
Open shift and Kubernetes) is supported.
- Replication from a Source site A (Db2 Warehouse Common Container to Target C (Db2 on Red Hat
Open shift and Kubernetes) is not supported.
Attention: You may require some shell scripts to configure and complete the
replication procedure below. All the required scripts are available in the
$BLUDR_SHARED_DIR/scripts/bin folder in the Q Replication container pod. You
can find the following shell scripts:
BLUDR_HOME=/opt/ibm/bludr
$BLUDR_HOME/scripts/bin/bludr-mq-cert-setup.sh;
$BLUDR_HOME/scripts/bin/bludr-restart-webserver.sh;
$BLUDR_HOME/scripts/bin/bludr-restart.sh;
$BLUDR_HOME/scripts/bin/bludr-perform-source-actions.sh
$BLUDR_HOME/scripts/bin/bludr-perform-target-actions.sh
$BLUDR_HOME/scripts/bin/bludr-perform-replication-configuration-actions.sh
$BLUDR_HOME/scripts/bin/bludr-add-tables-from-replset.sh
$BLUDR_HOME/scripts/bin/bludr-remove-tables-from-replset.sh
$BLUDR_HOME/scripts/bin/bludr-start-tables-in-replset.sh
$BLUDR_HOME/scripts/bin/bludr-stop-tables-in-replset.sh
Procedure
- Setup the Db2 Warehouse common container environment and alias
commands. This is your source site:
podman exec -it <Db2Wh_container_name> bash
su - dsadm ;
echo "export BLUDR_HOME=/opt/ibm/bludr ; export
BLUDR_WLP_HOME=/opt/ibm/apiserver/wlp/usr/servers/bludr ; " >> ~/.bash_profile ;
echo "alias ltr='ls -latr' ; alias rmf='rm -Rf' ; alias psa='ps -ef|grep asn | grep -v grep' ; alias psb='ps -
ef|grep bludr | grep -v grep' ; alias dbc='db2 connect to bludb' ; " >> ~/.bash_profile ;
. ~/.bash_profile ;
- Log in as a root user and run the following command to activate
replication on your source site:
podman exec <Db2Wh_container_name> bash -c "manage_features --name bludr --activate"
- Optional: If
Bludr
was removed previously IBM Message Queue certificates
must be refreshed:
$BLUDR_HOME/scripts/bin/bludr-mq-cert-setup.sh;
$BLUDR_HOME/scripts/bin/bludr-restart-webserver.sh;
$BLUDR_HOME/scripts/bin/bludr-restart.sh;
- After enabling replication on your target site, check the values
for LOCAL_CLUSTER_INFRA_HOSTNAME and LOCAL_DB2_HOSTNAME
parameters in the $BLUDR_SHARED_DIR/settings_backup/server.env file and
ASN.IBMQREP_RESTAPI_PROPERTIES
properties table:
- For the $BLUDR_SHARED_DIR/settings_backup/server.env file:
grep "LOCAL_CLUSTER_INFRA_HOSTNAME" $BLUDR_SHARED_DIR/settings_backup/server.env
grep "LOCAL_DB2_HOSTNAME" $BLUDR_SHARED_DIR/settings_backup/server.env
If the value does not appear as expected, update it to your desired
value:
sed -i 's/^LOCAL_CLUSTER_INFRA_HOSTNAME=incorrect.servername.abc.com/LOCAL_CLUSTER_INFRA_HOSTNAME=correct.servername.abc.com/' "$BLUDR_SHARED_DIR/settings_backup/server.env ;
sed -i 's/^LOCAL_DB2_HOSTNAME=incorrect.servername.abc.com/LOCAL_DB2_HOSTNAME=correct.servername.abc.com/' "$BLUDR_SHARED_DIR/settings_backup/server.env ;
To retrieve the hostname, run the following
command:
hostname -A | awk '{print $NF}'
- For the
ASN.IBMQREP_RESTAPI_PROPERTIES
properties table:
db2 connect to BLUDB
db2 "select * from ASN.IBMQREP_RESTAPI_PROPERTIES where PROP_KEY in ('LOCAL_CLUSTER_INFRA_HOSTNAME' , 'LOCAL_DB2_HOSTNAME' ) "
If the value does not appear as expected, update it to your desired
value:
db2 "update ASN.IBMQREP_RESTAPI_PROPERTIES set PROP_VALUE_CHAR = 'server.abc.com' where PROP_KEY in ('LOCAL_CLUSTER_INFRA_HOSTNAME' , 'LOCAL_DB2_HOSTNAME' )
Commit your changes:
db2 "commit"
For the changes to take effect, you must restart the
Bludr
server. Run the
following script:
$BLUDR_HOME/scripts/bin/bludr-restart.sh;
- Enable replication on your Db2 Warehouse common container source
site:
podman exec -it bash
su - dsadm ;
Run the
bludr-perform-source-actions.sh
script:
cd $BLUDR_HOME/scripts/bin;
./bludr-perform-source-actions.sh #Enter Option 1 for Listing Source.
./bludr-perform-source-actions.sh #Enter Option 2 to Enable Source.
Important: When enabling replication source, you must provide a replication username and
password. Your replication username should have dbadm
privileges as you may need to
make changes to database settings.
- Enable the Q Replication add on functionality on your Db2 Warehouse on Red Hat Openshift
and Kubernetes or Cloud Pak for Data environment. This is your target site:
- Follow Step
1 to Step 7
in the Deploying Replication using shell scripts
topic.
- Follow Step 1 to Step 7 in the
Configuring replication using shell scripts
topic.
- Run the
./bludr-perform-replication-configuration-actions.sh
script on
your target site:
cd $BLUDR_HOME/scritps/bin;
./bludr-perform-replication-configuration-actions.sh #Enter Option 1 to Collect the rest api properties.
Note: The
./bludr-perform-replication-configuration-actions.sh
scripts gathers the
following information:
- External Node port values
- QRep REST API server
- Database name
- Hostname
Ensure to record this information as it is required when configuring replication on the source
site.
- Transfer the
<cluster_infra_hostname_for_target_site_Db2U_SA>_<QRep_REST_External_NodePort>_properties.env
properties file to your source site manually.
- The
Bludr
REST API server, Q Replication
Capture/Apply, and Db2® server must exchange SSL certificates to communicate securely using Secure
Socket Layer (SSL). To perform this action, run the bludr-perform-target-actions.sh
script on your source site and select option 2:
cd $BLUDR_HOME/scritps/bin;
./bludr-perform-target-actions.sh #Enter Option 2 to Trust a target and exchange DB2 SSL Certificates.
Important: When running the ./bludr-perform-target-actions.sh
script,
you are prompted to enter properties for your Db2 Red Hat Openshift and Kubernetes or Cloud Pak for Data target site. You can obtain
that information from
<cluster_infra_hostname_for_target_site_Db2U_SA>_<QRep_REST_External_NodePort>_properties.env
properties file.
Note: You must enter the user credentials for your Db2 Warehouse Red Hat Open shift and Kubernetes
target site. A dedicated user
qrepdbadm
is created and the password for this user
can be obtained from kubernates secret object within the container. To retrieve the password for the
qrepdbadm
user, run the following
command:
cat /secrets/qrepdbadmpwd/password
- You must provide a target site to which you want to replicate the
data from your source site. To add a desired target site, run the
bludr-perform-target-actions.sh
script on your source and select option 3 on your
source site:
cd $BLUDR_HOME/scritps/bin;
./bludr-perform-target-actions.sh #Enter Option 3 to Add a target site.
- Run the
./bludr-perform-replication-configuration-actions.sh
script on your source site to
update the properties for your target site:
cd $BLUDR_HOME/scritps/bin;
./bludr-perform-replication-configuration-actions.sh #Enter Option 2 to Set the rest api properties.
Important: The properties are appended to the server.env on your
source site. Open the file and ensure that the target site properties are appended.
- Ensure that the Var DR_REMOTE_UI_PORT environment variable is present
in the $BLUDR_SHARED_DIR/settings_backup/server.env file:
DR_REMOTE_UI_PORT=<Target_SiteB_QRep_REST_External_NodePort>
Restart bludr.
cd $BLUDR_HOME/scripts/bin ; ./bludr-restart.sh;
What to do next
You can to create and manage replication sets as per your business needs. For more
information see, Operating replication using shell
scripts.