Deleting replication targets from a Q Replication configuration

You can remove target systems from your Db2 on Red Hat replication configuration. This action also deletes any replication sets that are associated with the targets.

Before you begin

This task is done on the cluster host for the replication source. Ensure that you have the following information before you run the API call:
  • The basic authorization token of the source on the cluster host.1
  • The host names of both the replication source and replication target databases.
  • The external port numbers of both the replication source and replication target databases.2
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
where source refers to either the source or destination database.
2 You can retrieve the external port numbers for both the replication source database and replication target 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

Deleting a target system from your Q Replication configuration produces the following results:

  • All replication sets for the target are removed.
  • The capture queue manager on the source is configured to remove communication to the target system.
  • All apply metadata tables are removed on the target database.
  • The queue manager and apply processes are stopped.
  • The apply message queue manager is removed on the target system.

Procedure

  1. Delete a replication set from your Q Replication configuration:
    curl --insecure -X DELETE --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic <your_authorization_token>' -d '{ "dbUsername": “<target_database_user_name>”, "dbPassword": “<target _database_user_password>” }' 'https://<source_hostname>:<source_rest_port>/dr/v1/target/<target_hostname>/<target_db_port>/BLUDB'
    Note: If you want to delete only target artifacts on the source without deleting the information on the target, include the property, "isSrcOrphan”:true;. The default value is false.
    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 target deletion:
    curl --insecure -X GET --header 'Accept: application/json' --header 'Authorization: Basic <your_authorization_token>' 
    'https://<source_hostname>:<source_rest_external_port>/dr/v1/target/progress/<job_number>'

Results

The deletion of the replication target 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 target deletion API call. It also includes sample code to show the response syntax.
HTTP Status Code Reason Response Model
202 Target deletion queued The user request returns a job (id) and URL as the API call starts (sample value):

{
  "id": 11,
  "url": " https://dr-source1.ibm.com:31023/dr/v1/target/progress/11"
}
200 Status check of API is successful Look for executionState=COMPLETED and overallJobResult=PASS in the response.
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 removing a replication target from a replication configuration. See step 1:
curl --insecure -X DELETE --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic ZHNhZG06MDNRVWlMczFhcmoxb3ky' -d '{ "dbUsername": "myuser1", "dbPassword": "mypass1" }' 'https://dr.source1.ibm.com:dr.source1.ibm.com/dr/v2/target/dr.target2.ibm.com/32621/BLUDB'
Use the returned job number to check for the delete target progress. See step 2:

curl --insecure -X GET --header 'Accept: application/json' --header 'Authorization: Basic ZHNhZG06aFRjT3dTTjR1RFo0N1Ew' 'https://api.dr-source1.ibm.com:30674/dr/v1/target/progress/11'

What to do next

Managing replication with the Db2 Q Replication REST API