Creating a DB Instance
API Description
This API is used to create cluster and replica set instances.
Restrictions
This API supports both yearly/monthly and pay-per-use DB instances.
URI
Name |
Type |
IN |
Mandatory |
Description |
---|---|---|---|---|
X-Auth-Token |
string |
header |
Yes |
User token obtained from IAM. For details, see Authentication. |
project_id |
string |
path |
Yes |
Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID. |
Requests
- Parameter description
Table 2 Parameter description Name
Type
Mandatory
Description
name
String
Yes
The DB instance name.
The instance name can be the same as an existing name.
The instance name must contain 4 to 64 characters and must start with a letter. It is case sensitive and can contain letters, digits, hyphens (-), and underscores (_). It cannot contain other special characters.
datastore
Object
Yes
The database information. For details, see Table 3.
region
String
Yes
The region ID.
The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.
availability_zone
String
Yes
AZ ID. You can select multiple AZs to create a cross-AZ cluster based on az_status returned by the API described in Querying Database Specifications.
The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.
vpc_id
String
Yes
The VPC ID. To obtain this parameter value, use either of the following methods:
- Method 1: Log in to VPC console and view the VPC ID on the VPC details page.
- Method 2: Query the VPC ID through the VPC API. For details, see Querying VPCs.
subnet_id
String
Yes
The network ID of the subnet. To obtain this parameter value, use either of the following methods:
- Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.
- Method 2: Query the network ID through the VPC API. For details, see Querying Subnets.
security_group_id
String
Yes
- Specifies the ID list of the security groups which a specified DB instance belongs to.
- To use multiple security groups for a DDS instance, choose Service Tickets > Create Service Ticket in the upper right corner of the management console to apply for the required permissions.
- You can add up to 10 security group IDs for each instance and separate them with commas (,).
- You can obtain it in either of the following ways:
- Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page.
- Method 2: Query the security group through the VPC API. For details, see Querying Security Groups.
port
String
No
Database access port
Value range: 2100 to 65535 (excluding 12017 and 33071)
If this parameter is not transferred, the port of the created DB instance is 8635 by default.
password
String
No
The database password.
The value must be 8 to 32 characters in length and contain uppercase letters (A to Z), lowercase letters (a to z), digits (0 to 9), and special characters, such as ~!@#%^*-_=+?
Enter a strong password to improve security, preventing security risks such as brute force cracking.
If this parameter is not transferred, set a password for the instance before connecting to the instance. For details, see Resetting the Administrator Password.
disk_encryption_id
String
No
The key ID used for disk encryption. The string must comply with UUID regular expression rules.
If this parameter is not transferred, disk encryption is not performed.
mode
String
Yes
The instance type. Cluster and replica set instances are supported.
Valid value:
- Sharding
- ReplicaSet
configurations
Array of objects
No
Parameter group configuration information. For details, see Table 4.
If this parameter is not transferred, the default parameter group is used.
flavor
Array of objects
Yes
The instance specifications. For more information, see Table 5.
For details about how to obtain the value, see the response values of flavor in Querying Database Specifications.
backup_strategy
Object
No
The advanced backup policy. For more information, see Table 6.
enterprise_project_id
String
No
The enterprise project ID.
- This parameter is not transferred for users who have not enabled the enterprise multi-project service.
- If this parameter is not transferred for a user who has enabled the enterprise multi-project service, the value is the default enterprise project.
To obtain the enterprise project ID, see the id value in the enterprise_project field data structure table in section "Querying the Enterprise Project List" of the Enterprise Management API Reference.
ssl_option
String
No
Specifies whether to enable or disable SSL.
Valid value:
- The value 0 indicates that SSL is disabled by default.
- The value 1 indicates that SSL is enabled by default.
- If this parameter is not transferred, SSL is disabled by default.
dss_pool_id
String
No
The dedicated storage ID of the DeC user. The value is left blank by default. Only DeC users support this parameter.
server_group_policies
Array of strings
No
The names of the policies associated with the ECS group of the DeC user. Only DeC users support this parameter.
The values are as follows:
- anti-affinity indicates that anti-affinity deployment is enabled for the DDS instance. To ensure high availability, the primary, secondary, and hidden nodes are created on different physical machines.
- If this parameter is not specified for Dec users, anti-affinity deployment is disabled by default.
tags
Array of objects
No
Tags
A maximum of 20 tags can be added for each instance. For details, see Table 7.
charge_info
Object
No
Billing mode, which includes yearly/monthly and pay-per-use. The default billing mode is pay-per-use.
For details, see Table 8.
Table 3 Data structure of the datastore field Name
Type
Mandatory
Description
type
String
Yes
The database type. The value is DDS-Community.
version
String
Yes
The database version. Versions 5.0, 4.4, 4.2, 4.0, and 3.4 are supported. The value can be 5.0, 4.4, 4.2, 4.0, or 3.4.
storage_engine
String
Yes
The storage engine. DDS supports the WiredTiger and RocksDB storage engines.
- If the database version is 4.2 or later and the storage engine is RocksDB, the value is rocksDB.
- If the database version is 4.0 or 3.4 and the storage engine is WiredTiger, the value is wiredTiger.
Table 4 Data structure of the Configurations field Parameter
Type
Mandatory
Description
type
String
Yes
Node type. Valid value:
- For a cluster instance, the value can be mongos, shard, or config.
- For a replica set instance, the value is replica.
Enumerated values:
- mongos
- shard
- config
- replica
configuration_id
String
Yes
Parameter group ID. For details, see Table 4.
Table 5 Data structure of the flavor field Name
Type
Mandatory
Description
type
String
Yes
The node type.
Valid value:
- For a cluster instance, the value can be mongos, shard, or config.
- For a replica set instance, the value is replica.
num
String
Yes
Number of nodes or groups.
Valid value:
- If the value of type is mongos, num indicates the number of mongos nodes in the cluster instance. The value ranges from 2 to 16.
- If the value of type is shard, num indicates the number of shard groups in the cluster instance. The value ranges from 2 to 16.
- If the value of type is config, num indicates the number of config groups in the cluster instance. The value can only be 1.
- If the value of type is replica, num indicates the number of replica nodes in the replica set instance. The value can be 3, 5, or 7.
storage
String
No
The disk type.
The value can be:- ULTRAHIGH: SSD storage.
- EXTREMEHIGH: extreme SSD storage.
This parameter is valid for the shard and config nodes of a cluster instance and for replica set instances. This parameter is invalid for mongos nodes. Therefore, you do not need to specify the storage space for mongos nodes.
size
String
No
The disk size.
This parameter is mandatory for all nodes except mongos. This parameter is invalid for the mongos nodes.
The value must be a multiple of 10. The unit is GB.
- For a cluster instance, the storage space of a shard node can be 10 to 2,000 GB, and the config storage space is 20 GB. This parameter is invalid for mongos nodes. Therefore, you do not need to specify the storage space for mongos nodes.
- For a replica set instance, the value ranges from 10 to 3000.
spec_code
String
Yes
Resource specification code. For details about how to obtain the code, see the value of response parameter spec_code in Querying Database Specifications.
In a cluster instance, multiple specifications need to be specified. All specifications must be of the same series, that is, general-purpose (s6), enhanced (c3), or enhanced II (c6).
Example:- dds.mongodb.s6.large.4.mongos and dds.mongodb.s6.large.4.config have the same specifications.
- dds.mongodb.s6.large.4.mongos and dds.mongodb.c3.large.4.config are not of the same specifications.
Table 6 Data structure of the backup_strategy field Name
Type
Mandatory
Description
start_time
String
Yes
The backup time window. Automated backups will be triggered during the backup time window.
The value cannot be empty. It must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format.
- The HH value must be 1 greater than the hh value.
- The values of mm and MM must be the same and must be set to 00.
- If this parameter is not transferred, the default backup time window is set to 00:00-01:00.
Example value:
23:00-00:00
keep_days
String
No
The number of days to retain the generated backup files.
The value range is from 0 to 732.
- If this parameter is set to 0, the automated backup policy is not set.
- If this parameter is not transferred, the automated backup policy is enabled by default. Backup files are stored for seven days by default.
Table 7 Data structure of the tags field Name
Type
Mandatory
Description
key
String
Yes
Tag key. The value can contain a maximum of 36 unicode characters.
The key cannot be left blank or an empty string.
The character set is as follows: A-Z, a-z, 0-9, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF).
value
String
Yes
Tag value. It contains a maximum of 43 Unicode characters. The value can be an empty string.
The character set is as follows: A-Z, a-z, 0-9, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF).
Table 8 Data structure of the charge_info field Parameter
Type
Mandatory
Description
charge_mode
String
Yes
Billing mode. Value range:
- prePaid: indicates the yearly/monthly billing mode.
- postPaid: indicates the pay-per-use billing mode.
period_type
String
No
Subscription period. This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:
- month: The service is subscribed by month.
- year: The service is subscribed by year.
period_num
Integer
No
This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:
- If period_type is set to month, the parameter value ranges from 1 to 9.
- If period_type is set to year, the parameter value ranges from 1 to 3.
is_auto_renew
Boolean
No
Whether automatic renewal is enabled for yearly/monthly instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal. Value range:
- true: indicates that the subscription is automatically renewed.
- false: indicates that the subscription is not automatically renewed. The default value is false.
is_auto_pay
Boolean
No
Payment method. When creating a yearly/monthly DB instance, you can specify whether to automatically pay with your account. This parameter does not affect the payment method of automatic renewal. Value range:
- true: indicates that the fee is automatically paid from the account.
- false: indicates that the fee is manually paid from the account. This payment method is used by default.
The values of region and availability_zone are used as examples.
Example Request
- Creating a cluster instance whose version is DDS 3.2, storage engine is WiredTiger, VPC, subnet, security group, and parameter template are configured, SSL is enabled, and tags are added
{ "name": "test-cluster-01", "datastore": { "type": "DDS-Community", "version": "3.2", "storage_engine": "wiredTiger" }, "region": "aaa", "availability_zone": "az1xahz", "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007", "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", "password": "******", "mode": "Sharding", "configurations": [ { "type": "mongos", "configuration_id": "acb288dbd1174f26a8960b45591bd98apr02" }, { "type": "shard", "configuration_id": "5bca546f0be64b038124ef9cedd1bfa1pr02" }, { "type": "config", "configuration_id": "4d123b3ba8294921802b11bf4d8c5735pr02" } ], "flavor": [ { "type": "mongos", "num": 2, "spec_code": "dds.mongodb.c6.medium.4.mongos" }, { "type": "shard", "num": 2, "storage": "ULTRAHIGH", "size": 20, "spec_code": "dds.mongodb.c6.medium.4.shard" }, { "type": "config", "num": 1, "storage": "ULTRAHIGH", "size": 20, "spec_code": "dds.mongodb.c6.large.2.config" } ], "backup_strategy": { "start_time": "08:15-09:15", "keep_days": 8 }, "ssl_option": 1, "dss_pool_id": "f5f84ed7-6f19-4bd4-99d7-b450ad6cc4dd", "server_group_policies": [ "anti-affinity" ], "tags": [ { "key": "dds001", "value": "dds001" } ] }
- Creating a cross-AZ cluster instance whose version is DDS 3.4, storage engine is WiredTiger, VPC, subnet, security group, and parameter template are configured, SSL is enabled, and tags are added
{ "name": "test-cluster-01", "datastore": { "type": "DDS-Community", "version": "3.4", "storage_engine": "wiredTiger" }, "region": "aaa", "availability_zone": "aaa,bbb,ccc", "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", "password": "******", "mode": "Sharding", "flavor": [ { "type": "mongos", "num": 2, "spec_code": "dds.mongodb.c6.medium.4.mongos" }, { "type": "shard", "num": 2, "storage": "ULTRAHIGH", "size": 20, "spec_code": "dds.mongodb.c6.medium.4.shard" }, { "type": "config", "num": 1, "storage": "ULTRAHIGH", "size": 20, "spec_code": "dds.mongodb.c6.large.2.config" } ], "backup_strategy": { "start_time": "23:00-00:00", "keep_days": "8" }, "ssl_option":"1", "tags" : [{ "key" : "dds001", "value" : "dds001" }] }
- Creating a replica set instance whose version is DDS 3.2, storage engine is WiredTiger, VPC, subnet, security group, and parameter template are configured, SSL is enabled, and tags are added
{ "name": "test-replicaset", "datastore": { "type": "DDS-Community", "version": "3.2", "storage_engine": "wiredTiger" }, "region": "aaa", "availability_zone": "az1xahz", "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007", "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", "password": "******", "mode": "ReplicaSet", "configurations": [ { "type": "replica", "configuration_id": "f17e3aad778440fbb68603c8c9032003pr02" } ], "flavor": [ { "type": "replica", "num": 1, "storage": "ULTRAHIGH", "size": 30, "spec_code": "dds.mongodb.c6.medium.4.repset" } ], "backup_strategy": { "start_time": "08:15-09:15", "keep_days": 8 }, "ssl_option": 1, "tags": [ { "key": "dds001", "value": "dds001" } ] }
Responses
- Parameter description
Table 9 Parameter description Name
Type
Mandatory
Description
id
String
No
Indicates the DB instance ID.
name
String
No
Same as the request parameter.
datastore
Object
No
Indicates the database information, which is the same as the request parameter. For more information, see Table 10.
created
String
No
Indicates the creation time in the following format: yyyy-mm-dd hh:mm:ss.
status
String
No
Indicates the DB instance status. The value is creating.
region
String
No
Indicates the region ID, which is the same as the request parameter.
availability_zone
String
No
Indicates the AZ ID, which is the same as the request parameter.
vpc_id
String
No
Indicates the VPC ID, which is the same as the request parameter.
subnet_id
String
No
Indicates the network ID of the subnet, which is the same as the request parameter.
security_group_id
String
No
Indicates the security group ID list, which is the same as the request parameter.
port
Integer
No
Indicates the database port.
disk_encryption_id
String
No
Indicates the ID of the disk encryption key, which is the same as the request parameter.
mode
String
No
Indicates the instance type, which is the same as the request parameter.
configurations
Array of objects
No
Parameter group configuration information.
For details, see Table 11.
flavor
Array of objects
No
Indicates the instance specification, which is the same as the request parameter. For more information, see Table 12.
backup_strategy
Object
No
Indicates the advanced backup policy, which is the same as the request parameter. For more information, see Table 13.
enterprise_project_id
String
No
Indicates the enterprise project ID. If the value is 0, the resource belongs to the default enterprise project.
ssl_option
String
No
Indicates whether to enable SSL, which functions the same as the request parameter.
dss_pool_id
String
No
Indicates the DSS storage pool ID, which is the same as the request parameter.
job_id
String
No
Indicates the ID of the workflow for creating a DB instance.
tags
Array of objects
No
Tag list, which is the same as the request parameter.
For details, see Table 14.
order_id
String
No
The ID of the order for creating an instance. This parameter is returned only when you create a yearly/monthly instance.
charge_info
Object
No
Billing mode, which is the same as the request parameter.
For details, see Table 15.
Table 10 Data structure of the datastore field Name
Type
Mandatory
Description
type
String
Yes
The database type. The value is DDS-Community.
version
String
Yes
The database version. Versions 5.0, 4.4, 4.2, 4.0, and 3.4 are supported. The value can be 5.0, 4.4, 4.2, 4.0, or 3.4.
storage_engine
String
Yes
The storage engine. DDS supports the WiredTiger and RocksDB storage engines.
- If the database version is 4.2 or later and the storage engine is RocksDB, the value is rocksDB.
- If the database version is 4.0 or 3.4 and the storage engine is WiredTiger, the value is wiredTiger.
Table 11 Data structure of the Configurations field Parameter
Type
Mandatory
Description
type
String
Yes
Node type. Valid value:
- For a cluster instance, the value can be mongos, shard, or config.
- For a replica set instance, the value is replica.
Enumerated values:
- mongos
- shard
- config
- replica
configuration_id
String
Yes
Parameter group ID. For details, see Table 4.
Table 12 Data structure of the flavor field Name
Type
Mandatory
Description
type
String
Yes
Node type.
num
String
Yes
Number of nodes or groups.
storage
String
No
Disk type.
size
String
No
Disk size.
spec_code
String
Yes
Resource specification code.
Table 13 Data structure of the backup_strategy field Name
Type
Mandatory
Description
start_time
String
Yes
The backup time window. Automated backups will be triggered during the backup time window.
keep_days
String
No
The number of days to retain the generated backup files.
Table 14 Data structure of the tags field Name
Type
Mandatory
Description
key
String
Yes
Tag key. The value can contain a maximum of 36 unicode characters.
The key cannot be left blank or an empty string.
The character set is as follows: A-Z, a-z, 0-9, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF).
value
String
Yes
Tag value. It contains a maximum of 43 Unicode characters. The value can be an empty string.
The character set is as follows: A-Z, a-z, 0-9, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF).
Table 15 Data structure of the charge_info field Parameter
Type
Mandatory
Description
charge_mode
String
Yes
Billing mode. Value range:
- prePaid: indicates the yearly/monthly billing mode.
- postPaid: indicates the pay-per-use billing mode.
period_type
String
No
Subscription period. This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:
- month: The service is subscribed by month.
- year: The service is subscribed by year.
period_num
Integer
No
This parameter is valid and mandatory only when charge_mode is set to prePaid. Value range:
- If period_type is set to month, the parameter value ranges from 1 to 9.
- If period_type is set to year, the parameter value ranges from 1 to 3.
is_auto_renew
Boolean
No
Whether automatic renewal is enabled for yearly/monthly instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal. Value range:
- true: indicates that the subscription is automatically renewed.
- false: indicates that the subscription is not automatically renewed. The default value is false.
is_auto_pay
Boolean
No
Payment method. When creating a yearly/monthly DB instance, you can specify whether to automatically pay with your account. This parameter does not affect the payment method of automatic renewal. Value range:
- true: indicates that the fee is automatically paid from the account.
- false: indicates that the fee is manually paid from the account. This payment method is used by default.
The values of region and availability_zone are used as examples.
- Response example
{ "id": "39b6a1a278844ac48119d86512e0000bin02", "name": "test-cluster-01", "datastore": { "type": "DDS-Community", "version": "3.4", "storage_engine": "wiredTiger" }, "created": "2019-01-16 09:34:36", "status": "creating", "region": "aaa", "availability_zone": "az1xahz", "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5", "disk_encryption_id": "2gfdsh-844a-4023-a776-fc5c5fb71fb4", "mode": "Sharding", "configurations": [ { "type": "mongos", "configuration_id": "acb288dbd1174f26a8960b45591bd98apr02" }, { "type": "shard", "configuration_id": "5bca546f0be64b038124ef9cedd1bfa1pr02" }, { "type": "config", "configuration_id": "4d123b3ba8294921802b11bf4d8c5735pr02" } ], "flavor": [ { "type": "mongos", "num": 2, "spec_code": "dds.mongodb.c6.medium.4.mongos" }, { "type": "shard", "num": 2, "storage": "ULTRAHIGH", "spec_code": "dds.mongodb.c6.medium.4.shard", "size": 20 }, { "type": "config", "num": 1, "storage": "ULTRAHIGH", "spec_code": "dds.mongodb.c6.large.2.config", "size": 20 } ], "backup_strategy": { "start_time": "08:15-09:15", "keep_days": "8" }, "enterprise_project_id": "", "ssl_option": "1", "dss_pool_id": "f5f84ed7-6f19-4bd4-99d7-b450ad6cc4dd", "job_id": "c010abd0-48cf-4fa8-8cbc-090f093eaa2f", "tags": [ { "key": "dds001", "value": "dds001" } ] }
SDK
Click Document Database Service DDS SDK to download the SDK or view the SDK document. To learn how to install and authenticate an SDK, read the Usage section.
Status Code
For more information, see Status Code.
Error Code
For more information, see Error Code.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot