This section describes how to use GaussDB(DWS) APIs to manage clusters. The procedure of the management clusters is as follows:
The following values are examples (replace them based on the actual situation).
Perform the following operations to manage the cluster.
curl -H "Content-type:application/json" https://{iam_endpoint}/v3/auth/tokens -X POST -d '{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "testname", "domain": { "name": "testname" }, "password": "Passw0rd" } } }, "scope": { "project": { "name": "eu-de" } } } }' -v -k
X-Subject-Token:MIidkgYJKoZIhvcNAQcCoIidgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
export Token={X-Subject-Token}
export Token=MIidkgYJKoZIhvcNAQcCoIidgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
curl -X GET -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/node_types -v -k
The request response is as follows:
status CODE 200 { "node_types": [ { "spec_name": "dws.d1.xlarge", "id": "ebe532d6-665f-40e6-a4d4-3c51545b6a67", "detail": [ { "type": "vCPU", "value": "4" }, { "value": "1675", "type": "LOCAL_DISK", "unit": "GB" }, { "type": "mem", "value": "32", "unit": "GB" } ] }, { "spec_name": "dws.m1.xlarge.ultrahigh", "id": "ebe532d6-665f-40e6-a4d4-3c51545b4f71", "detail": [ { "type": "vCPU", "value": "4" }, { "value": "512", "type": "SSD", "unit": "GB" }, { "type": "mem", "value": "32", "unit": "GB" } ] } ] }
The examples for configuring the cluster are as follows:
curl -X POST -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" -d '{ "node_type": "dws.d1.xlarge", "number_of_node": 3, "subnet_id": "d23ef2e9-8b90-49b3-bc4a-fd7d6bea6bec", "security_group_id": "12e3c23a-8710-4b75-95e4-5c8d7f68ef3c", "vpc_id": "219ab8a0-1272-4049-a383-8ad0b770fa11", "port": 8000, "name": "dws-demo", "user_name": "dbadmin", "user_pwd": "Dws2017demo!", "public_ip": { "public_bind_type": "auto_assign" } }' https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/clusters -v -k
If status code 200 is returned, the request for creating a cluster is successfully sent.
curl -X GET -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/clusters -k –v
The request response is as follows:
{ "clusters": [ { "id": "7ba031f6-81f4-4670-ad20-c490b91877e5", "status": "AVAILABLE", "sub_status": "NORMAL", "task_status": null, "action_progress": null, "node_type": "dws.d1.xlarge", "subnet_id": "d23ef2e9-8b90-49b3-bc4a-fd7d6bea6bec", "security_group_id": "12e3c23a-8710-4b75-95e4-5c8d7f68ef3c", "number_of_node": 3, "availability_zone": "eu-de-01", "port": 8000, "name": "dws-demo", "version": "1.1.0", "vpc_id": "219ab8a0-1272-4049-a383-8ad0b770fa11", "user_name": "dbadmin", "public_ip": { "public_bind_type": "auto_assign", "eip_id": "85b20d7e-9eb7-4b2a-98f3-3c8843ea3574" }, "public_endpoints": [ { "public_connect_info": "10.0.0.8:8000", "jdbc_url": "jdbc:postgresql://10.0.0.8:8000/<YOUR_DATABASE_name>" } ], "endpoints": [ { "connect_info": "192.168.0.10:8000", "jdbc_url": "jdbc:postgresql://192.168.0.10:8000/<YOUR_DATABASE_name>" }, { "connect_info": "192.168.0.12:8000", "jdbc_url": "jdbc:postgresql://192.168.0.12:8000/<YOUR_DATABASE_name>" } ] , "updated": "2018-01-15T12:50:06", "created": "2018-01-15T12:50:06", "recent_event": 1 } ] }
curl -X GET -H "Content-type:application/json" -H "X-Auth-Token:$Token" https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/clusters/7ba031f6-81f4-4670-ad20-c490b91877e5 -k -v
The request response is as follows:
{ "cluster": { "id": "7ba031f6-81f4-4670-ad20-c490b91877e5", "status": "AVAILABLE", "name": "dws-demo", "updated": "2018-01-15T12:50:06", "created": "2018-01-15T12:50:06", "user_name": "dbadmin", "sub_status": "NORMAL", "task_status": null, "action_progress": null, "node_type": "dws.d1.xlarge", "node_type_id": "5ddb1071-c5d7-40e0-a874-8a032e81a697", "subnet_id": "d23ef2e9-8b90-49b3-bc4a-fd7d6bea6bec", "security_group_id": "12e3c23a-8710-4b75-95e4-5c8d7f68ef3c", "number_of_node": 3, "availability_zone": "eu-de-01", "port": 8000, "vpc_id": "219ab8a0-1272-4049-a383-8ad0b770fa11", "public_ip": { "public_bind_type": "auto_assign", "eip_id": "85b20d7e-9eb7-4b2a-98f3-3c8843ea3574" }, "public_endpoints": [ { "public_connect_info": "10.0.0.8:8000", "jdbc_url": "jdbc:postgresql://10.0.0.8:8000/<YOUR_DATABASE_name>" } ], "endpoints": [ { "connect_info": "192.168.0.10:8000", "jdbc_url": "jdbc:postgresql://192.168.0.10:8000/<YOUR_DATABASE_name>" }, { "connect_info": "192.168.0.12:8000", "jdbc_url": "jdbc:postgresql://192.168.0.12:8000/<YOUR_DATABASE_name>" } ], "version": "1.1.0", "maintain_window": { "day": "Wed", "start_time": "22:00", "end_time": "02:00" }, "recent_event": 1, "tags": null, "parameter_group": { "id": "157e9cc4-64a8-11e8-adc0-fa7ae01bbebc", "name": "Default-Parameter-Group-dws ", "status": "In-Sync" } } }
public_endpoints and endpoints can be queried from the response. After the cluster is successfully created, you can use public_endpoints or endpoints to access the cluster from an external source.
curl -X POST -H "Content-type:application/json" -H "X-Auth-Token:$Token" -d '{ "snapshot": { "name": "snapshotForDemoCluster", "cluster_id": "7ba031f6-81f4-4670-ad20-c490b91877e5", "description": "Snapshot description" } }' https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/snapshots -k -v
The request response is as follows:
{ "snapshot": { "id": "2a4d0f86-67cd-408a-8b66-017454fb7793" } }
If status code 200 is returned, the request for creating a snapshot is successfully sent. Record id so that the ID can be used when you query the snapshot details later.
curl -X GET -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/snapshots/2a4d0f86-67cd-408a-8b66-017454fb7793 -k -v
If the snapshot status in the response is AVAILABLE, the snapshot is successfully created. If the snapshot status is CREATING, the snapshot is being created.
{ "snapshot": { "id": "2a4d0f86-67cd-408a-8b66-017454fb7793", "name": "snapshotForDemoCluster", "description": "Snapshot description", "started": "2018-01-18T13:59:23Z", "finished": "2018-01-18T13:01:40Z", "size": 500, "status": "AVAILABLE", "type": "MANUAL", "cluster_id": "4f87d3c4-9e33-482f-b962-e23b30d1a18c" } }
curl -X POST -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" -d '{ "restore": { "name": "dws-restore" } }' https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/snapshots/2a4d0f86-67cd-408a-8b66-017454fb7793/actions -v -k
If status code 200 is returned, the cluster is successfully restored. You can check the cluster restoration status by performing operations in Querying Snapshot Details.
curl -X DELETE -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/snapshots/2a4d0f86-67cd-408a-8b66-017454fb7793 -v -k
If status code 202 is returned, the snapshot is successfully deleted.
curl -X DELETE -H 'Content-type:application/json;charset=utf-8' -H "X-Auth-Token:$Token" -d '{ "keep_last_manual_snapshot":0 }' https://{dws_endpoint}/v1.0/9bc552e6-19af-4326-800d-281a92984636/clusters/7ba031f6-81f4-4670-ad20-c490b91877e5 -v -k
If status code 202 is returned, the cluster is successfully deleted.