Creating a DB instance
Function
This API is used to create a GaussDB(for MySQL) DB instance
- Learn how to authorize and authenticate this API before using it.
- Before calling this API, obtain the required region and endpoint.
URI
- URI format
- Example
POST https://{Endpoint}/mysql/v3/0483b6b16e954cb88930a360d2c4e663/instances
- Parameter description
Table 1 Parameter description Name
Mandatory
Description
project_id
Yes
Project ID of a tenant in a region.
To obtain this value, see Obtaining a Project ID.
Request
|
Name |
Mandatory |
Type |
Description |
|---|---|---|---|
|
charge_info |
No |
Object |
Billing mode, which is yearly/monthly or pay-per-use (default setting). For details, see Table 3. |
|
name |
Yes |
String |
DB instance name. DB instances of the same type can have same names under the same tenant. The value must be 4 to 64 characters in length and start with a letter. It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_). |
|
datastore |
Yes |
Object |
Database information. For details, see Table 4. |
|
mode |
Yes |
String |
DB instance type, which is case-insensitive. Currently, only the cluster type is supported. |
|
flavor_ref |
Yes |
String |
Specification code. For details, see Table 3. |
|
vpc_id |
Yes |
String |
VPC ID. To obtain this value, use either of the following methods:
|
|
subnet_id |
Yes |
String |
Network ID. To obtain this value, use either of the following methods:
|
|
security_group_id |
No |
String |
Security group ID. If the network ACL is enabled for the subnet used by the created DB instance, this parameter is optional. If the network ACL is not enabled, this parameter is mandatory.
|
|
configuration_id |
No |
String |
Parameter template ID. |
|
password |
Yes |
String |
Database password. Valid value: The password is 8 to 32 characters long and must contain at least three types of the following: uppercase letters, lowercase letters, digits, and special characters (~!@#%^*-_=+?). You are advised to enter a strong password to improve security and prevent security risks such as brute force cracking. If you enter a weak password, the system automatically determines that the password is invalid. |
|
backup_strategy |
No |
Object |
Automated backup policy. For details, see Table 5. |
|
time_zone |
No |
String |
UTC time zone.
|
|
availability_zone_mode |
Yes |
String |
AZ type. The value can be single or multi. |
|
master_availability_zone |
If availability_zone_mode is set to multi, this parameter is mandatory. If availability_zone_mode is set to single, this parameter cannot be specified. |
String |
Primary AZ. |
|
slave_count |
Yes |
Integer |
Number of read-only nodes from 1 to 9. A DB instance contains up to 15 read replicas. |
|
region |
Yes |
String |
Region ID. The value cannot be empty. To obtain this value, see Regions and Endpoints. |
|
volume |
No |
Object |
Volume information. This parameter is optional during the creation of yearly/monthly DB instances. For details, see Table 6. |
|
enterprise_project_id |
No |
String |
Enterprise project ID. This parameter is mandatory when the enterprise project is enabled, and cannot be specified when the enterprise project is disabled. |
|
Name |
Mandatory |
Type |
Description |
|---|---|---|---|
|
charge_mode |
Yes |
String |
Billing mode. Valid value:
|
|
period_type |
No |
String |
Subscription period. Valid value:
|
|
period_num |
No |
Integer |
Subscription duration. This parameter is valid and mandatory if charge_mode is set to prePaid. Valid value:
|
|
is_auto_renew |
No |
String |
Whether automatic renewal is enabled for yearly/monthly DB instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal.
|
|
is_auto_pay |
No |
String |
Whether the order will be automatically paid after yearly/monthly DB instances are created. This parameter does not affect the payment method of automatic renewal.
|
|
Name |
Mandatory |
Type |
Description |
|---|---|---|---|
|
type |
Yes |
String |
DB engine. Currently, only gaussdb-mysql is supported. |
|
version |
Yes |
String |
DB version. For details about supported DB versions, see section Querying Version Information About a DB Engine. |
|
Name |
Mandatory |
Type |
Description |
|---|---|---|---|
|
start_time |
Yes |
String |
Automated backup start time. The automatic backup will be triggered within one hour after the time specified by this parameter. 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.
Example value:
|
|
Name |
Mandatory |
Type |
Description |
|---|---|---|---|
|
size |
Yes |
Integer |
Disk size. The default value is 40 GB. The value ranges from 40 GB to 128,000 GB and must be a multiple of 10. |
The value of region in the following is used as an example.
- Request example
{ "charge_info":{ "charge_mode":"postPaid" }, "region":"cn-north-4b", "name":"gaussdb-2d34", "datastore":{ "type":"gaussdb-mysql", "version":"8.0" }, "mode":"Cluster", "flavor_ref":"gaussdb.mysql.large.x86.4", "vpc_id":"f7ee62e2-9705-4523-ba49-a85ea1a1fa87", "subnet_id":"140af7bf-a9da-4dcf-8837-34199fd6d186", "security_group_id":"c7f69884-fe2b-4630-8114-70a11499d902", "configuration_id":"43570e0de32e40c5a15f831aa5ce4176pr07", "password":"Gauss_234", "backup_strategy":{ "start_time":"17:00-18:00" }, "time_zone":"UTC+08:00", "availability_zone_mode":"multi", "master_availability_zone":"az1pod1", "slave_count":1, "enterprise_project_id":"0" }
Response
- Normal response
Table 7 Parameter description Name
Type
Description
instance
Object
DB instance information.
For details, see Table 8.
job_id
String
DB instance creation task ID.
This parameter is returned only when pay-per-use DB instances are created.
order_id
String
Order ID. This parameter is returned only when yearly/monthly DB instances are created.
Table 8 instance field data structure description Name
Type
Description
id
String
DB instance ID.
name
String
DB instance name. DB instances of the same type can have same names under the same tenant.
The value must be 4 to 64 characters in length and start with a letter. It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_).
status
String
DB instance status.
This parameter is returned only when pay-per-use DB instances are created.
datastore
Object
DB information.
For details, see Table 9.
mode
String
DB instance type. Currently, only the cluster type is supported.
configuration_id
String
Parameter template ID.
port
String
Database port, which is the same as the request parameter.
backup_strategy
Object
Automated backup policy.
For details, see Table 10.
enterprise_project_id
String
Enterprise project ID.
region
String
Region ID.
availability_zone_mode
String
AZ type.
master_ availability_zone
String
Primary AZ ID.
vpc_id
String
VPC ID.
security_group_id
String
Security group ID.
subnet_id
String
Subnet ID.
flavor_ref
String
Specification code.
For details, see Table 3.
charge_info
Object
Billing mode, which is yearly/monthly or pay-per-use.
For details, see Table 11.
Table 9 datastore field data structure description Name
Type
Description
type
String
DB Engine
version
String
DB version.
Table 10 backup_strategy field data structure description Name
Type
Description
start_time
String
Backup time window. Automated backups will be triggered during the backup time window.
keep_days
Integer
Backup retention days.
Table 11 charge_info field data structure description Name
Type
Description
charge_mode
String
Billing mode, which is yearly/monthly or pay-per-use.
period_num
Integer
Subscription duration, which is calculated by month.
This parameter is valid when charge_mode is set to prePaid (this parameter is valid only for yearly/monthly DB instances).
The values of region and master_availability_zone are used as examples.
- Example normal response
{ "instance":{ "id":"5eebbb4c0f9f4a99b42ed1b6334569aain07", "name":"gaussdb-2d34", "status":"BUILD", "datastore":{ "type":"gaussdb-mysql", "version":"8.0" }, "mode":"Cluster", "configuration_id": "", "port":null, "backup_strategy":{ "start_time":null, "keep_days":"7" }, "enterprise_project_id": "0", "region":"aaa", "availability_zone_mode":"multi", "master_availability_zone":"aaa", "vpc_id":"f7ee62e2-9705-4523-ba49-a85ea1a1fa87", "security_group_id":"c7f69884-fe2b-4630-8114-70a11499d902", "subnet_id":"140af7bf-a9da-4dcf-8837-34199fd6d186" "charge_info":{ "charge_mode":"postPaid" }, "flavor_ref":"gaussdb.mysql.large.x86.4" }, "job_id":"43672fe5-56bd-47f1-8fd1-595cded08a7c" }
Status Code
For details, see Status Codes.
Error Code
For details, see Error Codes.
Last Article: Managing DB Instances
Next Article: Querying a DB Instance List
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.