tencent cloud

Feedback

CreateDBInstance

Last updated: 2024-01-30 10:26:10

    1. API Description

    Domain name for API request: cdb.tencentcloudapi.com.

    This API is used to create a monthly subscribed TencentDB instance (which can be a source, disaster recovery, or read-only instance) by passing in information such as instance specifications, MySQL version number, purchased duration, and quantity.

    This is an asynchronous API. You can also use the DescribeDBInstances API to query the instance details. If the output parameter Status is 1 and the output parameter TaskStatus is 0, the instance has been successfully delivered.

    1. You can use the DescribeDBZoneConfig API to query the purchasable instance specifications, and then use the DescribeDBPrice API to query the prices of the purchasable instances.
    2. You can create up to 100 instances at a time, with an instance validity period of up to 36 months.
    3. MySQL v5.5, v5.6, v5.7, and v8.0 are supported.
    4. Source instances, read-only instances, and disaster recovery instances can be created.
    5. If Port, ParamList, or Password is specified in the input parameters, the instance (excluding basic instances) will be initialized.
    6. If Port, ParamTemplateId, or AlarmPolicyList is specified in the input parameters, you need to update your SDK to the latest version.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateDBInstance.
    Version Yes String Common Params. The value used for this API: 2017-03-20.
    Region No String Common Params. This parameter is not required for this API.
    Memory Yes Integer Instance memory size in MB. You can use the DescribeDBZoneConfig API to query the supported memory specifications.
    Volume Yes Integer Instance disk size in GB. You can use the DescribeDBZoneConfig API to query the supported disk specifications.
    Period Yes Integer Instance validity period in months. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36.
    GoodsNum Yes Integer Number of instances. Value range: 1-100. Default value: 1.
    Zone No String AZ information. The system will automatically select an AZ by default. You can use the DescribeDBZoneConfig API to query the supported AZs.
    UniqVpcId No String VPC ID. If this parameter is not passed in, the basic network will be selected by default. You can use the DescribeVpcs API to query the VPCs.
    UniqSubnetId No String VPC subnet ID. If UniqVpcId is set, then UniqSubnetId will be required. You can use the DescribeSubnets API to query the subnet lists.
    ProjectId No Integer Project ID. If this parameter is left empty, the default project will be used. When you purchase read-only instances and disaster recovery instances, the project ID is the same as that of the source instance by default.
    Port No Integer Custom port. Value range: 1024-65535.
    InstanceRole No String Instance typeA. Valid values: master (source instance), dr (disaster recovery instance), ro (read-only instance).
    MasterInstanceId No String Instance ID. It is required when purchasing a read-only instance, which is the same as the source instance ID. You can use the DescribeDBInstances API to query the instance ID.
    EngineVersion No String MySQL version. Valid values: 5.5, 5.6, 5.7, and 8.0. You can use the DescribeDBZoneConfig API to query the supported instance versions.
    Password No String The root account password, which can contain 8-64 characters and must contain at least two of the following types of characters: letters, digits, and symbols _+-&=!@#$%^*(). This parameter applies to source instances but not to read-only or disaster recovery instances.
    ProtectMode No Integer Data replication mode. Valid values: 0 (async replication), 1 (semi-sync replication), 2 (strong sync replication). Default value: 0.
    DeployMode No Integer Multi-AZ or single-AZ. Valid values: 0 (single-AZ), 1 (multi-AZ). Default value: 0.
    SlaveZone No String Information of replica AZ 1, which is the Zone value by default.
    ParamList.N No Array of ParamInfo List of parameters in the format of ParamList.0.Name=auto_increment&ParamList.0.Value=1. You can use the DescribeDefaultParams API to query the configurable parameters.
    BackupZone No String Information of replica AZ 2, which is left empty by default. Specify this parameter when purchasing a source instance in the one-source-two-replica architecture.
    AutoRenewFlag No Integer Auto-renewal flag. Valid values: 0 (auto-renewal not enabled), 1 (auto-renewal enabled).
    MasterRegion No String Region information of the source instance, which is required when purchasing a read-only or disaster recovery instance.
    SecurityGroup.N No Array of String Security group parameter. You can use the DescribeProjectSecurityGroups API to query the security group details of a project.
    RoGroup No RoGroup Read-only instance parameter. This parameter must be passed in when purchasing read-only instances.
    InstanceName No String Instance name. For multiple instances purchased at one time, they will be distinguished by the name suffix number, such as instnaceName=db and goodsNum=3, and their instance names are db1, db2, and db3, respectively.
    ResourceTags.N No Array of TagInfo Instance tag information
    DeployGroupId No String Placement group ID
    ClientToken No String A string unique in 48 hours, which is supplied by the client to ensure that the request is idempotent. Its maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.
    DeviceType No String Instance isolation type. Valid values: UNIVERSAL (general instance), EXCLUSIVE (dedicated instance), BASIC (basic instance). Default value: UNIVERSAL.
    ParamTemplateId No Integer Parameter template ID
    AlarmPolicyList.N No Array of Integer Array of alarm policy IDs, which can be obtained through the OriginId field in the return value of the DescribeAlarmPolicy API of TCOP.
    InstanceNodes No Integer The number of nodes of the instance. To purchase a read-only instance or a basic instance, set this parameter to 1 or leave it empty. To purchase a three-node instance, set this parameter to 3 or specify the BackupZone parameter. If the instance to be purchased is a source instance and both BackupZone and this parameter are left empty, the value 2 will be used, which indicates the source instance will have two nodes.
    Cpu No Integer The number of the instance CPU cores. If this parameter is left empty, it will be subject to the Memory value.
    AutoSyncFlag No Integer Whether to automatically start disaster recovery synchronization. This parameter takes effect only for disaster recovery instances. Valid values: 0 (no), 1 (yes). Default value: 0.
    CageId No String Financial cage ID.
    ParamTemplateType No String Type of the default parameter template. Valid values: HIGH_STABILITY (high-stability template), HIGH_PERFORMANCE (high-performance template).
    AlarmPolicyIdList.N No Array of String The array of alarm policy names, such as ["policy-uyoee9wg"]. If the AlarmPolicyList parameter is specified, this parameter is invalid.
    DryRun No Boolean Whether to check the request without creating any instance. Valid values: true, false (default). After being submitted, the request will be checked to see if it is in correct format and has all required parameters with valid values. An error code is returned if the check failed, and RequestId is returned if the check succeeded. After a successful check, no instance will be created if this parameter is set to true, whereas an instance will be created and if it is set to false.
    EngineType No String Instance engine type. Valid values: InnoDB (default), RocksDB.
    Vips.N No Array of String The list of IPs for sources instances. Only one IP address can be assigned to a single source instance. If all IPs are used up, the system will automatically assign IPs to the remaining source instances that do not have one.

    3. Output Parameters

    Parameter Name Type Description
    DealIds Array of String Billing sub-order ID
    InstanceIds Array of String List of instance IDs
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Purchasing a source instance

    This example shows you how to purchase a source instance.

    Input Example

    POST / HTTP/1.1
    Host: cdb.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateDBInstance
    <Common request parameters>
    
    {
        "ResourceTags": [
            {
                "TagKey": "marchtest",
                "TagValue": [
                    "test1"
                ]
            }
        ],
        "Zone": "ap-guangzhou-3",
        "UniqVpcId": "vpc-0akbol5v",
        "ProjectId": "0",
        "InstanceRole": "master",
        "GoodsNum": "1",
        "Period": "1",
        "Volume": "25",
        "EngineVersion": "5.6",
        "UniqSubnetId": "subnet-fyrtjbqw",
        "Memory": "1000",
        "InstanceNodes": "2"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7",
            "InstanceIds": [
                "cdb-pn6gd5jp"
            ],
            "DealIds": [
                "20171201110011"
            ]
        }
    }
    

    Example2 Purchasing a read-only instance

    This example shows you how to purchase a read-only instance.

    Input Example

    POST / HTTP/1.1
    Host: cdb.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateDBInstance
    <Common request parameters>
    
    {
        "RoGroup": {
            "RoGroupMode": "allinone",
            "RoGroupName": "jersey_test",
            "RoMaxDelayTime": "5",
            "MinRoInGroup": "1",
            "RoOfflineDelay": "1"
        },
        "GoodsNum": "1",
        "InstanceRole": "ro",
        "MasterInstanceId": "cdb-fn3f9xpx",
        "Period": "1",
        "Volume": "100",
        "Memory": "4000"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7",
            "DealIds": [
                "20171205110051"
            ],
            "InstanceIds": [
                "cdbro-hlpl4ik9"
            ]
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    CdbError Backend or process error.
    FailedOperation.StatusConflict Task status conflict.
    InternalError.CauthError Authentication failed.
    InternalError.CdbError System error.
    InternalError.DatabaseAccessError Internal database error.
    InternalError.DfwError Security group operation error.
    InternalError.FtpError File transfer exception
    InternalError.TradeError Transaction system error.
    InternalError.UndefinedError Unknown error
    InternalError.VpcError VPC or subnet error.
    InvalidParameter Parameter error.
    InvalidParameter.InstanceNotFound The instance does not exist.
    OperationDenied Operation denied.
    OperationDenied.ActionNotSupport Unsupported operation.
    OperationDenied.OtherOderInProcess There are other orders being submitted. Please try again later.
    OperationDenied.UserHasNoStrategy This account is not authorized to access the requested resource.
    OperationDenied.WrongPassword Incorrect password or verification failed.