Help Center/ GaussDB(DWS)/ API Reference/ Application Cases/ Using Postman to Call the API for Creating a Cluster
Updated on 2024-04-18 GMT+08:00

Using Postman to Call the API for Creating a Cluster

Scenario

Use Postman to create a GaussDB(DWS) cluster. This API is an asynchronous API. It takes 10 to 15 minutes to create a cluster. For details, see Calling APIs.

Preparations

  • You have registered a Huawei Cloud account and enabled Huawei Cloud services.
  • You have obtained the endpoint addresses of GaussDB(DWS) in the region you choose. For details, see Regions and Endpoints.
  • You have obtained the username, password, account name, and project ID of your Huawei Cloud account. In the upper right corner of the Huawei Cloud management console, choose My Credentials > API Credential. The username, account name, user password, and region project ID is displayed in the Projects area. For details about how to obtain the project ID, see Obtaining a Project ID.
  • You have created a VPC and obtained the VPC and subnet IDs. For details, see Virtual Private Cloud (VPC).

Procedure

  1. Configure the environment.

    Download Postman (7.24.0 is recommended) and call the snapshot creation service.

  2. Obtain the token for authentication.

    1. Create a POST request on Postman, select the Body tab, and enter the username, password, account name, and project ID.

      The region where the Huawei Cloud service for obtaining the token is located must be the same as the region where the called service is located. Otherwise, the calling fails.

    2. Click Send in the upper right corner to send POST https://iam.ap-southeast-1.myhuaweicloud.com/v3/auth/tokens. Obtain the value of Headers->X-Subject-Token in the command output. (The validity period of the token is 24 hours.)

  3. Call the API for creating a cluster.

    1. Create a POST request on Postman, select Headers, add the corresponding KEY and VALUE, and copy the token value to X-Auth-Token.
    2. Call the API. This service provides two APIs for creating a cluster. The region of the request URL must be the same as that of the invoked service. project_id indicates the project ID (mandatory). For details about how to obtain the project ID, see Preparations.
      • v1 API:
        POST https://{Endpoint}/v1.0/{project_id}/clusters
      • v2 API:
        POST https://{Endpoint}/v2/{project_id}/clusters

      The v2 API is recommended.

    3. Click Body and add the request parameter values to the request. Parameters vary by services. For details, see the API Description.
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      {
          "cluster": {
              "flavor": "dwsx2.rt.xlarge.m6",
              "num_node": 3,
              "subnet_id": "050e154d-9954-4929-b6d3-12af7c9213ac",
              "security_group_id": "",
              "vpc_id": "050e154d-9954-4929-b6d3-12af7c9213ac",
              "db_port": 8000,
              "datastore_version": "8.1.3.320",
              "availability_zones": [
                  "cn-north-4c"
              ],
              "name": "dws1",
              "num_cn": 3,
              "db_name": "dbadmin",
              "db_password": "Passw0rd!",
              "public_ip": {
                  "public_bind_type": "auto_assign",
                  "eip_id": ""
              },
              "volume": {
                  "volume": "SSD",
                  "capacity": "100"
              }
          }
      }
      
    4. Click Send in the upper right corner to send the request. For example, enter "POST https://dws.ap-southeast-1.myhuaweicloud.com/v2/89cd04f168b84af6be287f71730fdb4b/clusters" to view the creation result.
      {
        "cluster" : {
          "id" : "7d85f602-a948-4a30-afd4-e84f47471c15"
        }
      }

FAQs

  • DWS.5207 Invalid CN instance quantity.

    In the latest version, the number of CNs in the cluster ranges from 2 to the number of cluster nodes. The maximum value is 20 and the default value is 3.

  • DWS.5240 The selected flavor does not exist.

    If you use the v2 API, enter the flavor name but not the flavor ID.

  • ECS.0319 Failed to create a cluster, and the error message "The capacity of flavor am7.xlarge.8 is not sufficient." is displayed.

    The underlying resources for the selected flavor are insufficient. Check the flavor field and select an available flavor.