百度智能云

All Product Document

          Cloud Database MONGODB

          Create Sharded Cluster Instance

          Create an Sharded Cluster Instance

          Prerequisites

          Creating an instance requires identity verification. If failed to pass the identity verification, you can access the identity verification under the security authentication on the Baidu AI Cloud official website console for the identity verification.

          Description

          • This interface is used to create a DocDB for MongoDB instance with the same configuration. Currently, you can only create one instance once.
          • To create a prepaid instance, the account cash balance is required to be greater than or equal to the instance fee.
          • If the interface is asynchronously created, you can query the instance status via the designated instance details interface.

          Request structure

          POST /v{version}/instance?clientToken={clientToken} HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string
          {
              "billing":{
                  "paymentTiming": paymentTiming,
                  "reservation": {
                      "reservationLength": reservationLength
                  }
              },
              "engineVersion": dbVersion,
              "storageEngine": dbEngine,
              "mongosCount": mognosCount,
              "mongosCpuCount": mongosCpuCount,
              "mongosMemoryCapacity": mongosMemoryCapacity,
              "shardCount": shardCount,
              "shardCpuCount": shardCount,
              "shardMemoryCapacity": shardMemoryCapacity,
              "shardStorage": shardStorage,
              "dbInstanceName": dbName,
              "accountPassword": password,
              "vpcId": vpcId,
              "subnets":[
                  {
                      "zoneName": zoneName,
                      "subnetId": subnetId
                  }
              ]
          }

          Request header field

          No other special header fields are available except for the common header fields.

          Request parameter

          Parameter Name Type Required? Parameter Position Description
          version string Yes URL Parameter API version number
          clientToken string Yes Query Parameters It is an idempotent Token, which is an ASCII character string with a length of no more than 64 bits.
          billing Billing Yes RequestBody parameter Order and billing-related parameters Structural and value references
          purchaseCount int No RequestBody Parameters The number of instances created in batch. It supports the creation of one instance once, whose default value is 1.
          dbInstanceName string No RequestBody parameters The instance name is customized by users according to the following requirements:
          1) Uppercase and lowercase letters, numbers, Chinese characters, and special characters, such as “-”, "", "_” , “/”, “.”, are supported, and it must begin with a letter;
          2) The length is limited to 1–65 characters;
          3) It is not specified by default. If not specified, it is automatically generated at random.
          storageEngine string Yes RequestBody parameters Storage engine. Value Reference
          engineVersion string Yes RequestBody Parameters Database version Value Reference
          dbInstanceType string No RequestBody Parameters Instance type. The default value is replica. Value Reference
          mongosCount int No RequestBody Parameters Number of Mongos nodes. To create an sharded cluster instance, this parameter is required Value range [2,32]
          mongosCpuCount int No RequestBody parameters The CPU specification of the Mongos node. To create an sharded cluster instance, this parameter is required Value Reference
          mongosMemoryCapacity int No RequestBody parameters Mongos node memory specification. To create an sharding cluster instance, this parameter is required Value Reference
          shardCount int No RequestBody Parameters Number of shard nodes. To create an sharding cluster instance, this parameter is required. The value range is [2,32].
          shardCpuCount int No RequestBody parameters Shard node CPU specification If create an sharding cluster instance, this parameter is required Value Reference
          shardMemoryCapacity int No RequestBody parameters Shard node memory specification. To create an sharded cluster instance, this parameter is required. Value Reference
          shardStorage int No RequestBody Parameters Shard node storage specification If create an sharding cluster instance, this parameter is required Value Reference
          accountPassword stri ng No RequestBody Parameters The password of the “root” account. If it is empty, it generates a random password. The password must have 8 to 32 characters. English characters, numbers, and symbols must exist at the same time. Of which, symbols are limited to "!", "@", "#", "$", "%", "^", "*", and "()". The password needs to be encrypted and transmitted. All passwords are encrypted by AES 128bit encryption algorithm. SK is used as the key and the encrypted binary byte stream needs to be converted to the hexadecimal byte and passed in to the server as a string. The installation steps are as follows: byte[] bCiphertext= AES(plaintext,SK) String strHex = HexStr(bCiphertext).
          vpcId string No RequestBody Parameters If not provided, the default vpc is selected. You can query the available vpc by calling the Query VPC List interface.
          subnets List SubnetModel No RequestBody Parameters If not provided, the default subnet is selected. The list of availability zones can be queried by calling the Query List of Availability Zones interface.

          Return header field

          There are no other special header fields except for the common header field.

          Return parameter

          Parameter Name Type Description
          dbInstanceSimpleModels List db Instance Simple Model Created Instance Information

          Request example

          POST /v1/instance?clientToken=be31b98c-5e41-4838-9830-9be700de5a20 HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
          
          {
              "billing":{
                  "paymentTiming": "Prepaid",
                  "reservation": {
                      "reservationLength": 1
                  }
              },
              "engineVersion": "3.4",
              "storageEngine": "WiredTiger",
              "mongosCount": 2,
              "mongosCpuCount": 1,
              mongosMemoryCapacity
              "shardCount": 2,
              "shardCpuCount": 1,
              "shardMemoryCapacity": 2,
              "shardStorage": 5,
              "dbInstanceName": "myInstance",
              "accountPassword": "be3A@12345",
              "vpcId":"vpc-jdni4sh8"
              "subnets":[
                  {
                      "zoneName": "cn-bj-a",
                      "subnetId": "sbn-ien9ahe"
                  }
              ]
          }

          Return example

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          {
              "dbInstanceSimpleModels" : [
          	    {
          	        "dbInstanceId": "m-gGWeCM",
          	        "connectionString: "mongodb://root:****@gGWeCMs7y.mongodb.bd.baidubce.com:27017,gGWeCMApo.mongodb.bd.baidubce.com:27017/admin",
          	        "port": "27017
          	    }
              ]
          }
          Previous
          Create Replica Cluster Instance
          Next
          Master-slave Switch between Replica Cluster Instance Nodes