Listing replication sets in a Db2 Q Replication configuration

You can request a list of the replication sets within your Db2 Q Replication configuration by using the Db2 Replication REST API.

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:

  • Your Db2® instance ID
  • 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 username and password of the replication source database.
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.*//')

About this task

Procedure

Retrieve the list of replication sets from your Db2 Q Replication configuration:
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'

Results

The replication set list request is complete when a response message that contains executionState=COMPLETED and overallJobResult=PASS is returned. Until these values are returned, examine the error code, message, and resolution in the response.
The following table lists the possible HTTP status codes and response messages for the replication set details request. It also includes sample code to show the response syntax.
HTTP Status Code Reason Response Model
200 List of replication sets The user request returns a job (id) and URL as the API call starts (sample value):

{
  "replicationSets": [
    {
      "rsName": "RS_MPP_2",
      "sourceHost": "dr-source1.ibm.com",
      "sourcePort": 31576,
      "sourceDatabase": "BLUDB",
      "targetHost": "dr-target1..ibm.com",
      "targetPort": 30138,
      "targetDatabase": "BLUDB",
      "consistencyGroups": [
        {
          "cgName": "RSMPP20001",
          "state": "ACTIVE",
          "alert": "NONE",
          "sourceState": "A",
          "sourceStateTime": 1676422252084,
          "targetState": "A",
          "targetStateTime": 1677360282268,
          "targetStateInfo": "ASN7526I",
          "lastConsistencyPoint": 1677377949000,
          "endToEndLatency": 0,
          "throughput": 0,
          "id": 8,
          "numOfActiveTables": 1,
          "numOfInactiveTables": 0,
          "numOfWaitingTables": 0,
          "numOfLoadingTables": 0,
          "numOfDelayedTables": 0,
          "numOfErrorTables": 0,
          "numOfTables": 1,
          "errors": []
        }
      ]
    },
    {
      "rsName": "RS_TEST2",
      "sourceHost": "dr-source1.ibm.com",
      "sourcePort": 31576,
      "sourceDatabase": "BLUDB",
      "targetHost": "dr-target3.ibm.com",
      "targetPort": 30138,
      "targetDatabase": "BLUDB",
      "consistencyGroups": [
        {
          "cgName": "apidrd0001",
          "state": "INACTIVE",
          "alert": "NONE",
          "sourceState": "I",
          "sourceStateTime": 1676419244157,
          "targetState": "A",
          "targetStateTime": 1677360282293,
          "targetStateInfo": "ASN7526I",
          "lastConsistencyPoint": -2208988800000,
          "endToEndLatency": 0,
          "throughput": 0,
          "id": -1,
          "numOfActiveTables": 0,
          "numOfInactiveTables": 0,
          "numOfWaitingTables": 0,
          "numOfLoadingTables": 0,
          "numOfDelayedTables": 0,
          "numOfErrorTables": 0,
          "numOfTables": 0,
          "errors": []
        }
      ]
    }
  ]
}
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 requesting the list of replication sets:
curl --insecure -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic ZHNhZG06MDNRVWlMczFhcmoxb3ky' 
'https://dr-source1.ibm.com:31023/dr/v1/replicationset'

What to do next

Listing the details of a replication set