调整集群节点
功能介绍
创建集群后,扩容/缩容集群Core节点或者Task节点。MRS集群创建成功后不支持调整Master节点数量,即不支持扩缩容Master节点。该接口不兼容Sahara。处于running状态的集群才允许扩容/缩容,其他状态则不允许扩容/缩容。 集群状态和集群ID可参考查询集群列表接口获取。 本章节的接口只支持流式集群、分析集群和混合集群,不支持自定义集群。
接口约束
无
调用方法
请参见如何调用API。
URI
PUT /v1.1/{project_id}/cluster_infos/{cluster_id}
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
service_id |
否 |
String |
参数解释: 服务ID,为扩展接口,预留此参数。用户不需要配置。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
plan_id |
否 |
String |
参数解释: 套餐ID,为扩展接口,预留此参数。用户不需要配置。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
parameters |
是 |
ClusterScalingParams object |
参数解释: 请求参数集合。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
previous_values |
否 |
Map<String,String> |
参数解释: 扩展接口,预留此参数。用户不需要配置。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
order_id |
否 |
String |
参数解释: 扩容/缩容时系统获取的订单号,用户不需要配置。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
scale_type |
是 |
String |
参数解释: 范围操作类型。 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
node_id |
是 |
String |
参数解释: 扩容/缩容时新增或者减少节点的ID标识,参数值固定为node_orderadd。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
node_group |
否 |
String |
参数解释: 扩容或缩容的节点组。 约束限制: 不涉及 取值范围:
默认取值: core_node_default_group |
skip_bootstrap_scripts |
否 |
String |
参数解释: 是否跳过引导操作。仅在创建集群时配置了引导操作且扩容时有意义,表示扩容时是否在新增节点上执行创建集群时指定的引导操作。 约束限制: 不涉及 取值范围:
默认取值: false |
scale_without_start |
否 |
Boolean |
参数解释: 扩容后是否启动扩容节点上的组件。 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
server_ids |
否 |
Array of strings |
参数解释: 缩容Task节点时指定待删除Task节点的ID列表。 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
instances |
是 |
Integer |
参数解释: 扩容或缩容的节点数。 约束限制:
-缩容时Core节点数大于3或者Task节点数大于0可以进行节点删除。例如,当前集群Core节点和Task节点数均为5,Core节点可缩容的节点数为2(5减去3),Task节点可缩容节点数为小于等于5。 取值范围: ≥1 默认取值: 不涉及 |
task_node_info |
否 |
TaskNodeInfo object |
参数解释: Task节点规格。 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
node_size |
是 |
String |
参数解释: Task节点的实例规格,例如:{ECS_FLAVOR_NAME}.linux.bigdata,{ECS_FLAVOR_NAME}可以为c3.4xlare.2等在MRS购买页可见的云服务器规格。实例规格详细说明请参见MRS所使用的弹性云服务器规格和MRS所使用的裸金属服务器规格。该参数建议从MRS控制台的集群创建页面获取对应区域对应版本所支持的规格。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
data_volume_type |
是 |
String |
参数解释: Task节点数据磁盘存储类别,目前支持SATA、SAS和SSD等。 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
data_volume_count |
是 |
Integer |
参数解释: Task节点数据磁盘存储数目。 约束限制: 不涉及 取值范围: 0-20 默认取值: 不涉及 |
data_volume_size |
是 |
Integer |
参数解释: Task节点数据磁盘存储大小。传值只需填数字,不需要带单位GB。 约束限制: 不涉及 取值范围: 100-32000 默认取值: 不涉及 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
result |
String |
参数解释: 操作结果。 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
请求示例
-
在MRS集群中扩容1个core节点。
PUT /v1.1/{project_id}/cluster_infos/{cluster_id} { "service_id" : "", "plan_id" : "", "parameters" : { "order_id" : "", "scale_type" : "scale_out", "node_id" : "node_orderadd", "node_group" : "core_node_default_group", "instances" : "1", "skip_bootstrap_scripts" : false, "scale_without_start" : false }, "previous_values" : { } }
-
当Task节点个数大于零时,在MRS集群中扩容1个Task节点。
PUT /v1.1/{project_id}/cluster_infos/{cluster_id} { "service_id" : "", "plan_id" : "", "parameters" : { "order_id" : "", "scale_type" : "scale_out", "node_id" : "node_orderadd", "node_group" : "task_node_default_group", "instances" : "1", "skip_bootstrap_scripts" : false, "scale_without_start" : false }, "previous_values" : { } }
-
当Task节点个数等于零时,在MRS集群中扩容1个规格为s3.xlarge.2.linux.bigdata 的Task节点。
PUT /v1.1/{project_id}/cluster_infos/{cluster_id} { "service_id" : "", "plan_id" : "", "parameters" : { "order_id" : "", "scale_type" : "scale_out", "node_id" : "node_orderadd", "node_group" : "task_node_default_group", "task_node_info" : { "node_size" : "s3.xlarge.2.linux.bigdata", "data_volume_type" : "SATA", "data_volume_count" : 2, "data_volume_size" : 600 }, "instances" : "1", "scale_without_start" : false }, "previous_values" : { } }
-
在MRS集群中缩容1个Core节点。
PUT /v1.1/{project_id}/cluster_infos/{cluster_id} { "service_id" : "", "plan_id" : "", "parameters" : { "order_id" : "", "scale_type" : "scale_in", "node_id" : "node_orderadd", "node_group" : "core_node_default_group", "instances" : "1" }, "previous_values" : { } }
-
在MRS集群中缩容1个Task节点
PUT /v1.1/{project_id}/cluster_infos/{cluster_id} { "service_id" : "", "plan_id" : "", "parameters" : { "order_id" : "", "scale_type" : "scale_in", "node_id" : "node_orderadd", "node_group" : "task_node_default_group", "instances" : "1" }, "previous_values" : { } }
-
在MRS集群中缩容指定的Task节点。
PUT /v1.1/{project_id}/cluster_infos/{cluster_id} { "service_id" : "", "plan_id" : "", "parameters" : { "order_id" : "", "scale_type" : "scale_in", "node_id" : "node_orderadd", "node_group" : "task_node_default_group", "instances" : "2", "server_ids" : [ "c9573435-7814-4b2c-9131-ad78b814414c", "a4951009-6a0f-4e7b-9c81-9d4bd1f8c537" ] }, "previous_values" : { } }
响应示例
状态码: 200
扩容/缩容集群Core节点或者Task节点成功。
{ "result" : "succeeded" }
SDK代码示例
SDK代码示例如下。
-
在MRS集群中扩容1个core节点。
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
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.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; import java.util.Map; import java.util.HashMap; public class UpdateClusterScalingSolution { 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); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterScalingRequest request = new UpdateClusterScalingRequest(); request.withClusterId("{cluster_id}"); ClusterScalingReq body = new ClusterScalingReq(); ClusterScalingParams parametersbody = new ClusterScalingParams(); parametersbody.withOrderId("") .withScaleType(ClusterScalingParams.ScaleTypeEnum.fromValue("scale_out")) .withNodeId("node_orderadd") .withNodeGroup("core_node_default_group") .withSkipBootstrapScripts("false") .withScaleWithoutStart(false) .withInstances(1); body.withParameters(parametersbody); body.withPlanId(""); body.withServiceId(""); request.withBody(body); try { UpdateClusterScalingResponse response = client.updateClusterScaling(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()); } } }
-
当Task节点个数大于零时,在MRS集群中扩容1个Task节点。
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
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.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; import java.util.Map; import java.util.HashMap; public class UpdateClusterScalingSolution { 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); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterScalingRequest request = new UpdateClusterScalingRequest(); request.withClusterId("{cluster_id}"); ClusterScalingReq body = new ClusterScalingReq(); ClusterScalingParams parametersbody = new ClusterScalingParams(); parametersbody.withOrderId("") .withScaleType(ClusterScalingParams.ScaleTypeEnum.fromValue("scale_out")) .withNodeId("node_orderadd") .withNodeGroup("task_node_default_group") .withSkipBootstrapScripts("false") .withScaleWithoutStart(false) .withInstances(1); body.withParameters(parametersbody); body.withPlanId(""); body.withServiceId(""); request.withBody(body); try { UpdateClusterScalingResponse response = client.updateClusterScaling(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()); } } }
-
当Task节点个数等于零时,在MRS集群中扩容1个规格为s3.xlarge.2.linux.bigdata 的Task节点。
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
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.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; import java.util.Map; import java.util.HashMap; public class UpdateClusterScalingSolution { 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); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterScalingRequest request = new UpdateClusterScalingRequest(); request.withClusterId("{cluster_id}"); ClusterScalingReq body = new ClusterScalingReq(); TaskNodeInfo taskNodeInfoParameters = new TaskNodeInfo(); taskNodeInfoParameters.withNodeSize("s3.xlarge.2.linux.bigdata") .withDataVolumeType(TaskNodeInfo.DataVolumeTypeEnum.fromValue("SATA")) .withDataVolumeCount(2) .withDataVolumeSize(600); ClusterScalingParams parametersbody = new ClusterScalingParams(); parametersbody.withOrderId("") .withScaleType(ClusterScalingParams.ScaleTypeEnum.fromValue("scale_out")) .withNodeId("node_orderadd") .withNodeGroup("task_node_default_group") .withScaleWithoutStart(false) .withInstances(1) .withTaskNodeInfo(taskNodeInfoParameters); body.withParameters(parametersbody); body.withPlanId(""); body.withServiceId(""); request.withBody(body); try { UpdateClusterScalingResponse response = client.updateClusterScaling(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()); } } }
-
在MRS集群中缩容1个Core节点。
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
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.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; import java.util.Map; import java.util.HashMap; public class UpdateClusterScalingSolution { 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); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterScalingRequest request = new UpdateClusterScalingRequest(); request.withClusterId("{cluster_id}"); ClusterScalingReq body = new ClusterScalingReq(); ClusterScalingParams parametersbody = new ClusterScalingParams(); parametersbody.withOrderId("") .withScaleType(ClusterScalingParams.ScaleTypeEnum.fromValue("scale_in")) .withNodeId("node_orderadd") .withNodeGroup("core_node_default_group") .withInstances(1); body.withParameters(parametersbody); body.withPlanId(""); body.withServiceId(""); request.withBody(body); try { UpdateClusterScalingResponse response = client.updateClusterScaling(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()); } } }
-
在MRS集群中缩容1个Task节点
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
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.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; import java.util.Map; import java.util.HashMap; public class UpdateClusterScalingSolution { 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); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterScalingRequest request = new UpdateClusterScalingRequest(); request.withClusterId("{cluster_id}"); ClusterScalingReq body = new ClusterScalingReq(); ClusterScalingParams parametersbody = new ClusterScalingParams(); parametersbody.withOrderId("") .withScaleType(ClusterScalingParams.ScaleTypeEnum.fromValue("scale_in")) .withNodeId("node_orderadd") .withNodeGroup("task_node_default_group") .withInstances(1); body.withParameters(parametersbody); body.withPlanId(""); body.withServiceId(""); request.withBody(body); try { UpdateClusterScalingResponse response = client.updateClusterScaling(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()); } } }
-
在MRS集群中缩容指定的Task节点。
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
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.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; public class UpdateClusterScalingSolution { 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); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterScalingRequest request = new UpdateClusterScalingRequest(); request.withClusterId("{cluster_id}"); ClusterScalingReq body = new ClusterScalingReq(); List<String> listParametersServerIds = new ArrayList<>(); listParametersServerIds.add("c9573435-7814-4b2c-9131-ad78b814414c"); listParametersServerIds.add("a4951009-6a0f-4e7b-9c81-9d4bd1f8c537"); ClusterScalingParams parametersbody = new ClusterScalingParams(); parametersbody.withOrderId("") .withScaleType(ClusterScalingParams.ScaleTypeEnum.fromValue("scale_in")) .withNodeId("node_orderadd") .withNodeGroup("task_node_default_group") .withServerIds(listParametersServerIds) .withInstances(2); body.withParameters(parametersbody); body.withPlanId(""); body.withServiceId(""); request.withBody(body); try { UpdateClusterScalingResponse response = client.updateClusterScaling(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()); } } }
-
在MRS集群中扩容1个core节点。
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 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 = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterScalingRequest() request.cluster_id = "{cluster_id}" parametersbody = ClusterScalingParams( order_id="", scale_type="scale_out", node_id="node_orderadd", node_group="core_node_default_group", skip_bootstrap_scripts="false", scale_without_start=False, instances=1 ) request.body = ClusterScalingReq( parameters=parametersbody, plan_id="", service_id="" ) response = client.update_cluster_scaling(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
当Task节点个数大于零时,在MRS集群中扩容1个Task节点。
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 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 = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterScalingRequest() request.cluster_id = "{cluster_id}" parametersbody = ClusterScalingParams( order_id="", scale_type="scale_out", node_id="node_orderadd", node_group="task_node_default_group", skip_bootstrap_scripts="false", scale_without_start=False, instances=1 ) request.body = ClusterScalingReq( parameters=parametersbody, plan_id="", service_id="" ) response = client.update_cluster_scaling(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
当Task节点个数等于零时,在MRS集群中扩容1个规格为s3.xlarge.2.linux.bigdata 的Task节点。
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 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 = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterScalingRequest() request.cluster_id = "{cluster_id}" taskNodeInfoParameters = TaskNodeInfo( node_size="s3.xlarge.2.linux.bigdata", data_volume_type="SATA", data_volume_count=2, data_volume_size=600 ) parametersbody = ClusterScalingParams( order_id="", scale_type="scale_out", node_id="node_orderadd", node_group="task_node_default_group", scale_without_start=False, instances=1, task_node_info=taskNodeInfoParameters ) request.body = ClusterScalingReq( parameters=parametersbody, plan_id="", service_id="" ) response = client.update_cluster_scaling(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
在MRS集群中缩容1个Core节点。
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 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 = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterScalingRequest() request.cluster_id = "{cluster_id}" parametersbody = ClusterScalingParams( order_id="", scale_type="scale_in", node_id="node_orderadd", node_group="core_node_default_group", instances=1 ) request.body = ClusterScalingReq( parameters=parametersbody, plan_id="", service_id="" ) response = client.update_cluster_scaling(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
在MRS集群中缩容1个Task节点
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 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 = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterScalingRequest() request.cluster_id = "{cluster_id}" parametersbody = ClusterScalingParams( order_id="", scale_type="scale_in", node_id="node_orderadd", node_group="task_node_default_group", instances=1 ) request.body = ClusterScalingReq( parameters=parametersbody, plan_id="", service_id="" ) response = client.update_cluster_scaling(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
在MRS集群中缩容指定的Task节点。
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 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 = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterScalingRequest() request.cluster_id = "{cluster_id}" listServerIdsParameters = [ "c9573435-7814-4b2c-9131-ad78b814414c", "a4951009-6a0f-4e7b-9c81-9d4bd1f8c537" ] parametersbody = ClusterScalingParams( order_id="", scale_type="scale_in", node_id="node_orderadd", node_group="task_node_default_group", server_ids=listServerIdsParameters, instances=2 ) request.body = ClusterScalingReq( parameters=parametersbody, plan_id="", service_id="" ) response = client.update_cluster_scaling(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
在MRS集群中扩容1个core节点。
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/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 := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateClusterScalingRequest{} request.ClusterId = "{cluster_id}" orderIdParameters:= "" nodeGroupParameters:= "core_node_default_group" skipBootstrapScriptsParameters:= "false" scaleWithoutStartParameters:= false parametersbody := &model.ClusterScalingParams{ OrderId: &orderIdParameters, ScaleType: model.GetClusterScalingParamsScaleTypeEnum().SCALE_OUT, NodeId: "node_orderadd", NodeGroup: &nodeGroupParameters, SkipBootstrapScripts: &skipBootstrapScriptsParameters, ScaleWithoutStart: &scaleWithoutStartParameters, Instances: int32(1), } planIdClusterScalingReq:= "" serviceIdClusterScalingReq:= "" request.Body = &model.ClusterScalingReq{ Parameters: parametersbody, PlanId: &planIdClusterScalingReq, ServiceId: &serviceIdClusterScalingReq, } response, err := client.UpdateClusterScaling(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
当Task节点个数大于零时,在MRS集群中扩容1个Task节点。
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/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 := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateClusterScalingRequest{} request.ClusterId = "{cluster_id}" orderIdParameters:= "" nodeGroupParameters:= "task_node_default_group" skipBootstrapScriptsParameters:= "false" scaleWithoutStartParameters:= false parametersbody := &model.ClusterScalingParams{ OrderId: &orderIdParameters, ScaleType: model.GetClusterScalingParamsScaleTypeEnum().SCALE_OUT, NodeId: "node_orderadd", NodeGroup: &nodeGroupParameters, SkipBootstrapScripts: &skipBootstrapScriptsParameters, ScaleWithoutStart: &scaleWithoutStartParameters, Instances: int32(1), } planIdClusterScalingReq:= "" serviceIdClusterScalingReq:= "" request.Body = &model.ClusterScalingReq{ Parameters: parametersbody, PlanId: &planIdClusterScalingReq, ServiceId: &serviceIdClusterScalingReq, } response, err := client.UpdateClusterScaling(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
当Task节点个数等于零时,在MRS集群中扩容1个规格为s3.xlarge.2.linux.bigdata 的Task节点。
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/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 := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateClusterScalingRequest{} request.ClusterId = "{cluster_id}" taskNodeInfoParameters := &model.TaskNodeInfo{ NodeSize: "s3.xlarge.2.linux.bigdata", DataVolumeType: model.GetTaskNodeInfoDataVolumeTypeEnum().SATA, DataVolumeCount: int32(2), DataVolumeSize: int32(600), } orderIdParameters:= "" nodeGroupParameters:= "task_node_default_group" scaleWithoutStartParameters:= false parametersbody := &model.ClusterScalingParams{ OrderId: &orderIdParameters, ScaleType: model.GetClusterScalingParamsScaleTypeEnum().SCALE_OUT, NodeId: "node_orderadd", NodeGroup: &nodeGroupParameters, ScaleWithoutStart: &scaleWithoutStartParameters, Instances: int32(1), TaskNodeInfo: taskNodeInfoParameters, } planIdClusterScalingReq:= "" serviceIdClusterScalingReq:= "" request.Body = &model.ClusterScalingReq{ Parameters: parametersbody, PlanId: &planIdClusterScalingReq, ServiceId: &serviceIdClusterScalingReq, } response, err := client.UpdateClusterScaling(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
在MRS集群中缩容1个Core节点。
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/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 := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateClusterScalingRequest{} request.ClusterId = "{cluster_id}" orderIdParameters:= "" nodeGroupParameters:= "core_node_default_group" parametersbody := &model.ClusterScalingParams{ OrderId: &orderIdParameters, ScaleType: model.GetClusterScalingParamsScaleTypeEnum().SCALE_IN, NodeId: "node_orderadd", NodeGroup: &nodeGroupParameters, Instances: int32(1), } planIdClusterScalingReq:= "" serviceIdClusterScalingReq:= "" request.Body = &model.ClusterScalingReq{ Parameters: parametersbody, PlanId: &planIdClusterScalingReq, ServiceId: &serviceIdClusterScalingReq, } response, err := client.UpdateClusterScaling(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
在MRS集群中缩容1个Task节点
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/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 := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateClusterScalingRequest{} request.ClusterId = "{cluster_id}" orderIdParameters:= "" nodeGroupParameters:= "task_node_default_group" parametersbody := &model.ClusterScalingParams{ OrderId: &orderIdParameters, ScaleType: model.GetClusterScalingParamsScaleTypeEnum().SCALE_IN, NodeId: "node_orderadd", NodeGroup: &nodeGroupParameters, Instances: int32(1), } planIdClusterScalingReq:= "" serviceIdClusterScalingReq:= "" request.Body = &model.ClusterScalingReq{ Parameters: parametersbody, PlanId: &planIdClusterScalingReq, ServiceId: &serviceIdClusterScalingReq, } response, err := client.UpdateClusterScaling(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
在MRS集群中缩容指定的Task节点。
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/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 := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateClusterScalingRequest{} request.ClusterId = "{cluster_id}" var listServerIdsParameters = []string{ "c9573435-7814-4b2c-9131-ad78b814414c", "a4951009-6a0f-4e7b-9c81-9d4bd1f8c537", } orderIdParameters:= "" nodeGroupParameters:= "task_node_default_group" parametersbody := &model.ClusterScalingParams{ OrderId: &orderIdParameters, ScaleType: model.GetClusterScalingParamsScaleTypeEnum().SCALE_IN, NodeId: "node_orderadd", NodeGroup: &nodeGroupParameters, ServerIds: &listServerIdsParameters, Instances: int32(2), } planIdClusterScalingReq:= "" serviceIdClusterScalingReq:= "" request.Body = &model.ClusterScalingReq{ Parameters: parametersbody, PlanId: &planIdClusterScalingReq, ServiceId: &serviceIdClusterScalingReq, } response, err := client.UpdateClusterScaling(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
扩容/缩容集群Core节点或者Task节点成功。 |
错误码
请参见错误码。