• Relational Database Service

rds
  1. Help Center
  2. Relational Database Service
  3. API Reference
  4. API Calling
  5. Examples
  6. Creating a Read Replica (v1)

Creating a Read Replica (v1)

Flow Chart

Figure 1 Process of creating a read replica for a primary DB instance

The overall process is as follows:

  1. Call List Datastore Version to obtain the database ID ($dbId) and database version ($version).
  2. Obtain the region. Define region as $region.

    For details about how to obtain this parameter value, see Regions and Endpoints.

  3. Call List Flavor to obtain the flavorRef ($flavorId). $dbId obtained in 1 and $region obtained in 2 are used in the request.
  4. Call List Database Instance to obtain the instance ID ($instanceId) of a tenant database.
  5. Call Create Read Replica. $flavorId obtained in 3 and $instanceId obtained in 4 are used in the request body.

API Calling

  1. Call List Datastore Version. For details, see 1 in section API Calling.
  2. Obtain the region. For details, see 2 in section API Calling.
  3. Call List Flavor. For details, see 3 in section API Calling.
  4. Run the following command to obtain the primary DB instance ID ($instanceId) as replicaOf, a parameter in the creating read replica request. Example request:
    curl -H "Content-Type: application/json" "X-Auth-Token: $X-Subject-Token" "X-Language: en-us"$SERVER_URL/v1/{project_id}/instances

    Example response:

    {
        "instances": {
            "id": "252f11f1-2912-4c06-be55-1999bde659c5",
            "status": "ACTIVE",
            "name": "trove-instance-rep3",
            "created": "2016-06-18T21:21:50+0200",
            "hostname": "",
            "type": "master",
            "region": "eu-de",
            "updated": "2016-06-18T21:21:50+0200",
            "availabilityZone": "eu-de-01",
            "vpc": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
            "nics": {
                "subnetId": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f"
            },
            "securityGroup": {
                "id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5"
            },
            "flavor": {
                "id": "bf07a6d4-844a-4023-a776-fc5c5fb71fb4"
            },
            "volume": {
                "type": "ULTRAHIGH",
                "size": 100,
            },
            "backupStrategy": {
                "startTime": "01:00:00",
                "keepDays": 3
            }
        }
    }
  5. Run the following command to create a read replica:
    curl -X POST $SERVER_URL/v1/{project_id}/instances -H "Content-Type: application/json" "X-Auth-Token: $X-Subject-Token" "X-Language: en-us" -d '{"instance": {"name": "tenant-instance-123-rep","flavorRef": "$flavorId","replicaOf": $instanceId }}'

    Example response:

    {
        "instance": {
            "id": "b0468a4a-5790-4a4f-8442-9030e52369e6",
            "status": "BUILD",
            "name": "tenant-instance-123-rep",
            "created": "",
            "hostname": "172.16.4.210",
            "type": "readreplica",
            "region": "eu-de"",
            "updated": "",
            "availabilityZone": "eu-de-01",
            "vpc": "490a4a08-ef4b-44c5-94be-3051ef9e4fce",
            "nics": {
                "subnetId": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f"
            },
            "securityGroup": {
                "id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5"
            },
            "flavor": {
                "id": "bf07a6d4-844a-4023-a776-fc5c5fb71fb4"
            },
            "volume": {
                "type": "ULTRAHIGH",
                "size": 100
            },
            "extendparam": {
                "jobs": [
                    {
                        "id": "8a3eb75e5577819f0155778220600001"
                    }
                ]
            },
            "replica_of": "252f11f1-2912-4c06-be55-1999bde659c5"
        }
    }