Adding a table to a replication set

You can add or remove tables from an existing replication set and change the set name.

Before you begin

This task is done on the cluster host for the replication source. Ensure that you collect the following information before you run the API call:

  • The basic authorization token of the source on the cluster host.1
  • The host name of the replication source database.
  • The external port number of the replication source database.2
  • The replication set name (rsName)3
  • The consistency group name (cgName)
  • The subscription name (subName)4
You need this information to run the needed Replication REST API calls.
1 You need to create a basic authorization token to run a cURL request. To create your token, run this command:
echo <source_db_username>:<source_db_password>| base64
2 You can retrieve the external port number of the replication source database by running the following command:
oc get svc | grep <db2_instance_id> | grep db2u-engn-svc | grep 50001 | sed 's/.*50001://' | sed 's/\/TCP.*//')
3 You can find the replication set name (rsName) and consistency group name (cgName) by running the following command:
curl --insecure -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic <your_authorization_token>' 
'https://<source_hostname>:<source_rest_port>/dr/v1/replicationset' 
4 When you have the rsName and cgName values, you can use them to find the subscription name (subName) by running the following command:
curl --insecure -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic <your_authorization_token>' 
'https://<source_hostname>:<source_rest_port>/dr/v1/<replication_set_name>/<consistency_group_name>' 

About this task

The replication set is identified by the replication set and consistency group names. Adding tables does not affect replication for the tables that are already in the set.
Note: If you specify true for skipLoad, the initial load for the new table is not loaded to target initially.

Procedure

  1. Add a table to an existing replication set:
    curl --insecure -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic <your_authorization_token>' -d '{ "sourceHost": "<source_host_name>", "sourceDatabase": "BLUDB", "sourcePort": <source_rest_port>, "targetHost": "<target_host_name>", "targetDatabase": "BLUDB", "targetPort": <target_rest_port>, "tables": [ { "sourceSchema": "<source_table_schema>, "sourceTable": "<source_table_name>", "skipLoad": false } ], }' 'https://dr-<source_hostname>:<source_rest_port>/dr/v1/replicationset/<replication_set_name>/<consistency_group_name>/table'
    This API call returns a job number (id).
    {
      "id": <job_number>,
      "url": "https://<source_hostname>:<source_rest_external_port>/dr/v1/target/progress/<job_number>"
    }
    
  2. Include the job number in the following API call to check the progress of the replication set creation:
    curl --insecure -X GET --header 'Accept: application/json' --header 'Authorization: Basic <your_authorization_token>' 
    'https://<source_hostname>:<source_rest_port>/dr/v1/replicationset/progress/<job_number>'

Results

When a table is added to a replication set with executionState=COMPLETED and overallJobResult=PASS in the response, the added table is ready to replicate. Until these values are returned, examine the error code, message, and resolution in the response.
HTTP Status Codes Reason Response Model
202 Table addition started The user request returns a successful response for the completion of the API call (sample value):
{
  "id": 9,
  "url": "https://dr-source1.ibm.com:31023/dr/v1/replicationset/progress/9
}

Sample value from replication set status retrieved:
{
   "id": 9,
  "url": "https://dr-source1.ibm.com:31023/dr/v1/replicationset/progress/9",
  "executionState": "COMPLETED",
  "overallJobResult": "PASS",
  "jobStatusList": [
    {
      "jobKey": "addTableCg",
      "jobDescription": "Add table(s) to consistency group for replication set.",
      "execState": "COMPLETED",
      "jobResult": "PASS",
      "values": [],
      "errors": []
    }
  ]
}
200 Status check on API is successful The user request returns a job (id) and URL as the API call starts (sample value):

{
  "id": 9,
  "url": "https://dr-source1.ibm.com:31023/dr/v1/replicationset/progress/9
}
4xx Client request error The user request was not fulfilled due to malformed request syntax or other client issues:
{
  "errorCode": "string",
  "errorMessage": "string",
  "errorResolution": "string"
}
5xx Server error The user request appeared valid, but was not fulfilled due to an issue with the server:
{
  "errorCode": "string",
  "errorMessage": "string",
  "errorResolution": "string"
}

Example

The following example shows the command syntax for adding a table to a replication set. See step 1:
curl --insecure -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic ZHNhZG06MDNRVWlMczFhcmoxb3ky' -d '{ "sourceHost": "dr-source1.ibm.com", "sourceDatabase": "BLUDB", "sourcePort": 32621, "targetHost": "dr-target2.ibm.com", "targetDatabase": "BLUDB", "targetPort": 30138, "tables": [ { "sourceSchema": "DRADMIN1", "sourceTable": "T5R", "skipLoad": false }, { "sourceSchema": "DRADMIN2", "sourceTable": "T5C", "skipLoad": false } ] }' 'https://dr-source1.ibm.com:31023/dr/v1/replicationset/DEMOREPLSET1/DEMORE0001/table'
The following example shows the command syntax for checking the status of the replication set creation by using the generated job number, 9. See step 2:
curl --insecure -X GET --header 'Accept: application/json' --header 'Authorization: Basic ZHNhZG06MDNRVWlMczFhcmoxb3ky' 'https://dr-source1.ibm.com:30674/dr/v1/replicationset/progress/5'

What to do next

Deleting one or more tables from a replication set