Adding Components to a Cluster - AddComponent
Function
This API is used to add new service components to an existing MRS cluster to extend its functions. The component addition feature is supported only for custom clusters running MRS 3.1.2 or later normal versions, as well as MRS 3.1.2-LTS.2 or later LTS versions.
Constraints
None
Debugging
You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and supports sample SDK code debugging.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, no identity policy-based permissions are required for calling this API.
URI
POST /v2/{project_id}/clusters/{cluster_id}/components
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. Constraints N/A Range The value must consist of 1 to 64 characters. Only letters and digits are allowed. Default Value N/A |
| cluster_id | Yes | String | Definition Cluster ID. For details about how to obtain the cluster ID, see Obtaining a Cluster ID. Constraints N/A Range The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-). Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| components_install_mode | Yes | Array of ComponentInstallMode objects | Definition Component model details, used to specify the components to be added to the cluster and their deployment information. For detailed parameter descriptions, see Table 3. Constraints N/A Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| component | Yes | String | Definition Component name Constraints N/A Range The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-). Default Value N/A |
| node_groups | Yes | Array of AssignedNodeGroup objects | Definition Role deployment information for the component. Each object specifies the role deployment configuration of the component in a node group. For detailed parameter descriptions, see Table 4. Constraints N/A Range N/A Default Value N/A |
| component_user_password | No | String | Definition User password of the component. The password is used for machine-machine account to connect to the ClickHouse component. The password: Constraints N/A Range
Default Value N/A |
| component_default_password | No | String | Definition Default user password of the component. The password is used for human-machine account to connect to the ClickHouse component. The password: Constraints N/A Range
Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition Node group name. Constraints N/A Range The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-). Default Value N/A |
| assigned_roles | Yes | Array of strings | Definition Role deployment information. You can specify the roles deployed in a node group. This parameter is a string array. Each string represents a role expression. Role expression definition:
Constraints The number of records cannot exceed 1,000. Range N/A Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| result | String | Definition Result of the request for updating a mapping. Range
|
Example Request
- Add the ClickHouse component to a cluster in normal mode.
POST /v2/f77c10d14a544393a24e5f0bf53202b6/clusters/ff879d3a-e5d5-4485-a9b6-c673b52673fa/components { "components_install_mode" : [ { "component" : "ClickHouse", "node_groups" : [ { "name" : "master_node_default_group", "assigned_roles" : [ "ClickHouseServer:1,2" ] }, { "name" : "node_group_1", "assigned_roles" : [ "ClickHouseServer", "ClickHouseBalancer" ] } ], "component_user_password" : "*****", "component_default_password" : "*****" } ] } - Add the HBase component.
POST /v2/f77c10d14a544393a24e5f0bf53202b6/clusters/ff879d3a-e5d5-4485-a9b6-c673b52673fa/components { "components_install_mode" : [ { "component" : "HBase", "node_groups" : [ { "name" : "master_node_default_group", "assigned_roles" : [ "RegionServer", "HMaster" ] } ] } ] }
Example Response
Status code: 200
Processing result of a request:
{
"result" : "succeeded"
} SDK Sample Code
The SDK sample code is as follows.
-
Add the ClickHouse component to a normal cluster.
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
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.v2.region.MrsRegion; import com.huaweicloud.sdk.mrs.v2.*; import com.huaweicloud.sdk.mrs.v2.model.*; import java.util.List; import java.util.ArrayList; public class AddComponentSolution { 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(); AddComponentRequest request = new AddComponentRequest(); request.withClusterId("{cluster_id}"); AddComponentsReq body = new AddComponentsReq(); List<String> listNodeGroupsAssignedRoles = new ArrayList<>(); listNodeGroupsAssignedRoles.add("ClickHouseServer"); listNodeGroupsAssignedRoles.add("ClickHouseBalancer"); List<String> listNodeGroupsAssignedRoles1 = new ArrayList<>(); listNodeGroupsAssignedRoles1.add("ClickHouseServer:1,2"); List<AssignedNodeGroup> listComponentsInstallModeNodeGroups = new ArrayList<>(); listComponentsInstallModeNodeGroups.add( new AssignedNodeGroup() .withName("master_node_default_group") .withAssignedRoles(listNodeGroupsAssignedRoles1) ); listComponentsInstallModeNodeGroups.add( new AssignedNodeGroup() .withName("node_group_1") .withAssignedRoles(listNodeGroupsAssignedRoles) ); List<ComponentInstallMode> listbodyComponentsInstallMode = new ArrayList<>(); listbodyComponentsInstallMode.add( new ComponentInstallMode() .withComponent("ClickHouse") .withNodeGroups(listComponentsInstallModeNodeGroups) .withComponentUserPassword("*****") .withComponentDefaultPassword("*****") ); body.withComponentsInstallMode(listbodyComponentsInstallMode); request.withBody(body); try { AddComponentResponse response = client.addComponent(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()); } } }
-
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.v2.region.MrsRegion; import com.huaweicloud.sdk.mrs.v2.*; import com.huaweicloud.sdk.mrs.v2.model.*; import java.util.List; import java.util.ArrayList; public class AddComponentSolution { 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(); AddComponentRequest request = new AddComponentRequest(); request.withClusterId("{cluster_id}"); AddComponentsReq body = new AddComponentsReq(); List<String> listNodeGroupsAssignedRoles = new ArrayList<>(); listNodeGroupsAssignedRoles.add("RegionServer"); listNodeGroupsAssignedRoles.add("HMaster"); List<AssignedNodeGroup> listComponentsInstallModeNodeGroups = new ArrayList<>(); listComponentsInstallModeNodeGroups.add( new AssignedNodeGroup() .withName("master_node_default_group") .withAssignedRoles(listNodeGroupsAssignedRoles) ); List<ComponentInstallMode> listbodyComponentsInstallMode = new ArrayList<>(); listbodyComponentsInstallMode.add( new ComponentInstallMode() .withComponent("HBase") .withNodeGroups(listComponentsInstallModeNodeGroups) ); body.withComponentsInstallMode(listbodyComponentsInstallMode); request.withBody(body); try { AddComponentResponse response = client.addComponent(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()); } } }
-
Add the ClickHouse component to a normal cluster.
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v2.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v2 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 = AddComponentRequest() request.cluster_id = "{cluster_id}" listAssignedRolesNodeGroups = [ "ClickHouseServer", "ClickHouseBalancer" ] listAssignedRolesNodeGroups1 = [ "ClickHouseServer:1,2" ] listNodeGroupsComponentsInstallMode = [ AssignedNodeGroup( name="master_node_default_group", assigned_roles=listAssignedRolesNodeGroups1 ), AssignedNodeGroup( name="node_group_1", assigned_roles=listAssignedRolesNodeGroups ) ] listComponentsInstallModebody = [ ComponentInstallMode( component="ClickHouse", node_groups=listNodeGroupsComponentsInstallMode, component_user_password="*****", component_default_password="*****" ) ] request.body = AddComponentsReq( components_install_mode=listComponentsInstallModebody ) response = client.add_component(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v2.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v2 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 = AddComponentRequest() request.cluster_id = "{cluster_id}" listAssignedRolesNodeGroups = [ "RegionServer", "HMaster" ] listNodeGroupsComponentsInstallMode = [ AssignedNodeGroup( name="master_node_default_group", assigned_roles=listAssignedRolesNodeGroups ) ] listComponentsInstallModebody = [ ComponentInstallMode( component="HBase", node_groups=listNodeGroupsComponentsInstallMode ) ] request.body = AddComponentsReq( components_install_mode=listComponentsInstallModebody ) response = client.add_component(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Add the ClickHouse component to a normal cluster.
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/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, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := mrs.NewMrsClient(hcClient) request := &model.AddComponentRequest{} request.ClusterId = "{cluster_id}" var listAssignedRolesNodeGroups = []string{ "ClickHouseServer", "ClickHouseBalancer", } var listAssignedRolesNodeGroups1 = []string{ "ClickHouseServer:1,2", } var listNodeGroupsComponentsInstallMode = []model.AssignedNodeGroup{ { Name: "master_node_default_group", AssignedRoles: listAssignedRolesNodeGroups1, }, { Name: "node_group_1", AssignedRoles: listAssignedRolesNodeGroups, }, } componentUserPasswordComponentsInstallMode:= "*****" componentDefaultPasswordComponentsInstallMode:= "*****" var listComponentsInstallModebody = []model.ComponentInstallMode{ { Component: "ClickHouse", NodeGroups: listNodeGroupsComponentsInstallMode, ComponentUserPassword: &componentUserPasswordComponentsInstallMode, ComponentDefaultPassword: &componentDefaultPasswordComponentsInstallMode, }, } request.Body = &model.AddComponentsReq{ ComponentsInstallMode: listComponentsInstallModebody, } response, err := client.AddComponent(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/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, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := mrs.NewMrsClient(hcClient) request := &model.AddComponentRequest{} request.ClusterId = "{cluster_id}" var listAssignedRolesNodeGroups = []string{ "RegionServer", "HMaster", } var listNodeGroupsComponentsInstallMode = []model.AssignedNodeGroup{ { Name: "master_node_default_group", AssignedRoles: listAssignedRolesNodeGroups, }, } var listComponentsInstallModebody = []model.ComponentInstallMode{ { Component: "HBase", NodeGroups: listNodeGroupsComponentsInstallMode, }, } request.Body = &model.AddComponentsReq{ ComponentsInstallMode: listComponentsInstallModebody, } response, err := client.AddComponent(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
| Status Code | Description |
|---|---|
| 200 | Request processing result. |
Error Codes
For details, see Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot