创建StarRocks实例
功能介绍
创建StarRocks实例。
调用方法
请参见如何调用API。
URI
POST /v3/{project_id}/instances/{instance_id}/starrocks
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
租户在某一Region下的project ID。 获取方法请参见获取项目ID。 |
instance_id |
是 |
String |
TaurusDB数据库实例ID,严格匹配UUID规则。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取。 请求响应成功后在响应消息头中包含的“X-Subject-Token”的值即为Token值。 |
Content-Type |
是 |
String |
内容类型。 取值:application/json。 |
X-Language |
否 |
String |
请求语言类型。默认en-us。 取值范围:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
实例名称。同一租户下,同类型的实例名可重名。 取值范围:最小为4个字符,最大为64个字符且不超过64个字节,必须以字母开头,区分大小写,可以包含字母、数字、中划线、下划线,不能包含其他特殊字符。不支持中文名。 |
engine |
是 |
engine object |
引擎信息。 |
ha |
是 |
ha object |
部署信息。 |
fe_flavor_id |
是 |
String |
FE节点规格ID。使用可通过查询HTAP规格响应消息中的“id”。 |
be_flavor_id |
是 |
String |
BE节点规格ID。使用可通过查询HTAP规格响应消息中的“id”。 |
db_root_pwd |
是 |
String |
数据库密码。 取值范围:至少包含以下字符的三种:大小写字母、数字和特殊符号~!@#$%^*-_=+?,()&|.,长度8~32个字符。 建议您输入高强度密码,以提高安全性,防止出现密码被暴力破解等安全风险。如果您输入弱密码,系统会自动判定密码非法。 |
fe_count |
是 |
Integer |
FE节点数。
|
be_count |
是 |
Integer |
BE节点数。
|
az_mode |
是 |
String |
可用区类型。 当前仅支持single。 |
fe_volume |
是 |
fe_volume object |
FE节点存储规格。 |
be_volume |
是 |
be_volume object |
BE节点存储规格。 |
az_code |
是 |
String |
可用区代码。 |
time_zone |
否 |
String |
时区。默认时区为UTC+08:00。 |
tags_info |
是 |
tags_info object |
标签信息。 |
security_group_id |
否 |
String |
实例安全组ID。默认与Taurus安全组ID一致。 |
pay_info |
否 |
pay_info object |
支付信息。包周期场景必填。 |
region_code |
否 |
String |
可用区。包周期场景必填。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
io_type |
是 |
String |
磁盘类型。通过查询HTAP引擎资源返回消息获取。 |
capacity_in_gb |
是 |
Integer |
磁盘容量,单位GB 增长的步长:10GB。 |
响应参数
状态码: 201
参数 |
参数类型 |
描述 |
---|---|---|
instance |
instance object |
实例信息。 |
job_id |
String |
工作流ID。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
StarRocks实例ID,严格匹配UUID规则。 |
az_code |
String |
可用区码。 |
az_mode |
String |
可用区模式。 取值范围: single:单可用区。 multi:多可用区。 |
name |
String |
实例名称。 |
engine |
engine object |
引擎信息。 |
vpc_id |
String |
虚拟私有云ID。 |
security_group_id |
String |
安全组ID。 |
sub_net_id |
String |
子网ID。 |
db_user |
String |
数据库用户。默认root。 |
port |
Integer |
数据库端口号。默认3306。 |
ha_mode |
String |
部署模式。 |
pay_info |
pay_info object |
计费信息。 |
enable_ssl |
Boolean |
SSL开关。 |
status |
String |
实例状态。 |
region |
String |
实例所在区域。 |
tags_info |
tags_info object |
实例标签。 |
参数 |
参数类型 |
描述 |
---|---|---|
pay_model |
String |
计费模式。
StarRocks实例当前只支持按需计费,默认值为0 |
order_id |
String |
包周期计费ID。 |
period |
String |
包周期周期。 |
period_type |
String |
包周期周期类型。 |
is_auto_renew |
String |
包周期是否自动续费。 |
参数 |
参数类型 |
描述 |
---|---|---|
tags |
Array of tags objects |
用户标签。默认为空。 |
sys_tags |
Array of sys_tags objects |
系统标签。 |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误消息。 |
状态码: 500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误消息。 |
请求示例
创建数据库实例
POST https://{endpoint}/v3/23a50154cf494ec9ad6883979a12db0a/instances/40dc4c5729f14aad893e2dcd5baf6a15in07/starrocks { "name" : "htap-ff64", "engine" : { "type" : "star-rocks", "version" : "3.1" }, "ha" : { "mode" : "Single" }, "fe_flavor_id" : "afef3bfd-ac7c-32e1-ba44-c388acbb196a", "be_flavor_id" : "de565db8-0a96-37ea-9388-61167624712c", "db_root_pwd" : "Test@123!", "fe_count" : 1, "be_count" : 1, "az_mode" : "single", "fe_volume" : { "io_type" : "SSD", "capacity_in_gb" : 50 }, "be_volume" : { "io_type" : "SSD", "capacity_in_gb" : 50 }, "az_code" : "cn-southwest-244b", "time_zone" : "UTC+08:00", "tags_info" : { "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "value" : "0" } ] } }
响应示例
状态码: 201
Success.
{ "instance" : { "id" : "590031445ef845bb912d7fc8243db80cin17", "az_code" : "cn-southwest-244b", "az_mode" : "single", "name" : "htap-ff64", "engine" : { "type" : "star-rocks", "version" : "3.1" }, "vpc_id" : "d5a1a29b-1476-490f-9682-c1a59593e7b0", "security_group_id" : "967a0ac2-3cae-4e57-a49a-d0f6ff07dcc1", "sub_net_id" : "2ce0bc80-bfc5-4d5e-9b78-a7f91572e03b", "db_user" : "root", "port" : 3306, "ha_mode" : "Single", "pay_info" : { "pay_model" : "0", "order_id" : null, "period" : null, "period_type" : null, "is_auto_renew" : null }, "enable_ssl" : false, "status" : "creating", "region" : "cn-southwest-244", "tags_info" : { "tags" : [ ], "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "value" : "0" } ] } }, "job_id" : "cf0b7506-1505-450f-9d95-ce9d93b6b5c3" }
SDK代码示例
SDK代码示例如下。
Java
创建数据库实例
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.gaussdb.v3.region.GaussDBRegion; import com.huaweicloud.sdk.gaussdb.v3.*; import com.huaweicloud.sdk.gaussdb.v3.model.*; import java.util.List; import java.util.ArrayList; public class CreateStarrocksInstanceSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); GaussDBClient client = GaussDBClient.newBuilder() .withCredential(auth) .withRegion(GaussDBRegion.valueOf("<YOUR REGION>")) .build(); CreateStarrocksInstanceRequest request = new CreateStarrocksInstanceRequest(); request.withInstanceId("{instance_id}"); StarRocksCreateRequest body = new StarRocksCreateRequest(); List<StarRocksCreateRequestTagsInfoSysTags> listTagsInfoSysTags = new ArrayList<>(); listTagsInfoSysTags.add( new StarRocksCreateRequestTagsInfoSysTags() .withKey(StarRocksCreateRequestTagsInfoSysTags.KeyEnum.fromValue("_sys_enterprise_project_id")) .withValue(StarRocksCreateRequestTagsInfoSysTags.ValueEnum.fromValue("0")) ); StarRocksCreateRequestTagsInfo tagsInfobody = new StarRocksCreateRequestTagsInfo(); tagsInfobody.withSysTags(listTagsInfoSysTags); StarRocksCreateRequestBeVolume beVolumebody = new StarRocksCreateRequestBeVolume(); beVolumebody.withIoType("SSD") .withCapacityInGb(50); StarRocksCreateRequestFeVolume feVolumebody = new StarRocksCreateRequestFeVolume(); feVolumebody.withIoType("SSD") .withCapacityInGb(50); StarRocksCreateRequestHa habody = new StarRocksCreateRequestHa(); habody.withMode(StarRocksCreateRequestHa.ModeEnum.fromValue("Single")); StarRocksCreateRequestEngine enginebody = new StarRocksCreateRequestEngine(); enginebody.withType("star-rocks") .withVersion("3.1"); body.withTagsInfo(tagsInfobody); body.withTimeZone("UTC+08:00"); body.withAzCode("cn-southwest-244b"); body.withBeVolume(beVolumebody); body.withFeVolume(feVolumebody); body.withAzMode(StarRocksCreateRequest.AzModeEnum.fromValue("single")); body.withBeCount(1); body.withFeCount(1); body.withDbRootPwd("Test@123!"); body.withBeFlavorId("de565db8-0a96-37ea-9388-61167624712c"); body.withFeFlavorId("afef3bfd-ac7c-32e1-ba44-c388acbb196a"); body.withHa(habody); body.withEngine(enginebody); body.withName("htap-ff64"); request.withBody(body); try { CreateStarrocksInstanceResponse response = client.createStarrocksInstance(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
创建数据库实例
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkgaussdb.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = GaussDBClient.new_builder() \ .with_credentials(credentials) \ .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateStarrocksInstanceRequest() request.instance_id = "{instance_id}" listSysTagsTagsInfo = [ StarRocksCreateRequestTagsInfoSysTags( key="_sys_enterprise_project_id", value="0" ) ] tagsInfobody = StarRocksCreateRequestTagsInfo( sys_tags=listSysTagsTagsInfo ) beVolumebody = StarRocksCreateRequestBeVolume( io_type="SSD", capacity_in_gb=50 ) feVolumebody = StarRocksCreateRequestFeVolume( io_type="SSD", capacity_in_gb=50 ) habody = StarRocksCreateRequestHa( mode="Single" ) enginebody = StarRocksCreateRequestEngine( type="star-rocks", version="3.1" ) request.body = StarRocksCreateRequest( tags_info=tagsInfobody, time_zone="UTC+08:00", az_code="cn-southwest-244b", be_volume=beVolumebody, fe_volume=feVolumebody, az_mode="single", be_count=1, fe_count=1, db_root_pwd="Test@123!", be_flavor_id="de565db8-0a96-37ea-9388-61167624712c", fe_flavor_id="afef3bfd-ac7c-32e1-ba44-c388acbb196a", ha=habody, engine=enginebody, name="htap-ff64" ) response = client.create_starrocks_instance(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
创建数据库实例
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := gaussdb.NewGaussDBClient( gaussdb.GaussDBClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateStarrocksInstanceRequest{} request.InstanceId = "{instance_id}" var listSysTagsTagsInfo = []model.StarRocksCreateRequestTagsInfoSysTags{ { Key: model.GetStarRocksCreateRequestTagsInfoSysTagsKeyEnum().SYSENTERPRISEPROJECTID, Value: model.GetStarRocksCreateRequestTagsInfoSysTagsValueEnum().E_0, }, } tagsInfobody := &model.StarRocksCreateRequestTagsInfo{ SysTags: listSysTagsTagsInfo, } beVolumebody := &model.StarRocksCreateRequestBeVolume{ IoType: "SSD", CapacityInGb: int32(50), } feVolumebody := &model.StarRocksCreateRequestFeVolume{ IoType: "SSD", CapacityInGb: int32(50), } habody := &model.StarRocksCreateRequestHa{ Mode: model.GetStarRocksCreateRequestHaModeEnum().SINGLE, } enginebody := &model.StarRocksCreateRequestEngine{ Type: "star-rocks", Version: "3.1", } timeZoneStarRocksCreateRequest:= "UTC+08:00" request.Body = &model.StarRocksCreateRequest{ TagsInfo: tagsInfobody, TimeZone: &timeZoneStarRocksCreateRequest, AzCode: "cn-southwest-244b", BeVolume: beVolumebody, FeVolume: feVolumebody, AzMode: model.GetStarRocksCreateRequestAzModeEnum().SINGLE, BeCount: int32(1), FeCount: int32(1), DbRootPwd: "Test@123!", BeFlavorId: "de565db8-0a96-37ea-9388-61167624712c", FeFlavorId: "afef3bfd-ac7c-32e1-ba44-c388acbb196a", Ha: habody, Engine: enginebody, Name: "htap-ff64", } response, err := client.CreateStarrocksInstance(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
201 |
Success. |
400 |
Client error. |
500 |
Server error. |
错误码
请参见错误码。