Updated on 2026-09-15 GMT+08:00

Creating a Cluster - CreateCluster

Function

This API is used to create an MRS cluster.

Before using the API, you need to obtain the resources listed in Table 1.

Table 1 Obtaining resources

Resource

How to Obtain

VPC

See Querying VPCs and Creating a VPC in Virtual Private Cloud (VPC) API Reference.

Subnet

See Querying Subnets and Creating a Subnet in Virtual Private Cloud (VPC) API Reference.

Key Pair

See Querying SSH Key Pairs and Creating and Importing an SSH Key Pair in Elastic Cloud Server (ECS) API Reference.

Zone

See Endpoints for details about regions and AZs.

Version

Currently, MRS 1.9.2, 3.1.0, 3.1.2-LTS.3, 3.1.5, 3.2.0-LTS.1, 3.3.0-LTS, 3.6.0-LTS, and 3.5.0-LTS are supported.

Component

  • MRS 3.6.0-LTS supports the following components:
    • A custom cluster can contain the following components: Hadoop, Spark, HBase, Hive, Kafka, Flume, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, JobGateway, ClickHouse, Guardian, MemArtsCC, Sqoop, Kudu, Impala, and MemArtsStore.
    • A Doris cluster can contain the following components:

      Doris

    • An analysis cluster can contain the following components: Hadoop, Spark, HBase, Hive, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, JobGateway, Guardian, MemArtsCC, Sqoop, Kudu, Impala, and MemArtsStore.
    • A streaming cluster can contain the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark, HBase, Hive, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, Kafka, Flume, JobGateway, Guardian, MemArtsCC, Sqoop, Kudu, Impala, and MemArtsStore.
  • MRS 3.5.0-LTS supports the following components:
    • A custom cluster can contain the following components: Hadoop, Spark, HBase, Hive, Kafka, Flume, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, ClickHouse, Guardian, JobGateway, MemArtsCC, Sqoop, Kudu, and Impala.
    • A Doris cluster can contain the following components:

      Doris

    • An analysis cluster contains the following components: Hadoop, Spark, HBase, Hive, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, JobGateway, Guardian, MemArtsCC, Sqoop, Kudu, and Impala.
    • A streaming cluster contains the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster contains the following components: Hadoop, Spark, HBase, Hive, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, Kafka, Flume, JobGateway, Guardian, MemArtsCC, Sqoop, Kudu, and Impala.
  • MRS 3.3.0-LTS supports the following components:
    • A custom cluster can contain the following components: CDL, Hadoop, Spark, HBase, Hive, IoTDB, Loader, Kafka, Flume, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, ClickHouse, Guardian, and JobGateway.
    • A Doris cluster can contain the following components:

      Doris

    • An analysis cluster contains the following components: Hadoop, Spark, HBase, Hive, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, JobGateway, Guardian, and Doris.
    • A streaming cluster contains the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark, HBase, Hive, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, Kafka, Flume, JobGateway, and Guardian.
  • MRS 3.2.0-LTS.1 supports the following components:
    • An analysis cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, and Guardian.
    • A streaming cluster can contain the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, Kafka, Flume, and Guardian.
    • A custom cluster can contain the following components: CDL, Hadoop, Spark2x, HBase, Hive, Hue, IoTDB, Loader, Kafka, Flume, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, and ClickHouse, and Guardian.
  • MRS 3.1.5 supports the following components:
    • An analysis cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, Kudu, Sqoop, and Guardian
    • A streaming cluster can contain the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, Kudu, Sqoop, Guardian, Kafka, and Flume.
    • A custom cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Kafka, Flume, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, ClickHouse, Kudu, Sqoop, and Guardian.
  • MRS 3.1.2-LTS.3 supports the following components:
    • An analysis cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, and Tez.
    • A streaming cluster can contain the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, Kafka, and Flume.
    • A custom cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Kafka, Flume, Flink, Oozie, ZooKeeper, HetuEngine, Ranger, Tez, and ClickHouse.
  • MRS 3.1.0 supports the following components:
    • An analysis cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, and Kudu.
    • A streaming cluster can contain the following components: Kafka, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, Kudu, Kafka, and Flume.
    • A custom cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Kafka, Flume, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, ClickHouse, and Kudu.
  • MRS 3.0.5 supports the following components:
    • An analysis cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, Kudu, and Alluxio.
    • A streaming cluster can contain the following components: Kafka, Storm, Flume, ZooKeeper, and Ranger.
    • A hybrid cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, Kudu, Alluxio, Kafka, Storm, and Flume.
    • A custom cluster can contain the following components: Hadoop, Spark2x, HBase, Hive, Hue, Loader, Kafka, Storm, Flume, Flink, Oozie, ZooKeeper, Ranger, Tez, Impala, Presto, ClickHouse, Kudu, and Alluxio.
  • MRS 2.1.0 supports the following components:
    • An analysis cluster can contain the following components: Presto, Hadoop, Spark, HBase, Hive, Hue, Loader, Tez, Impala, Kudu, and Flink.
    • A streaming cluster can contain the following components: Kafka, Storm, and Flume.
  • MRS 1.9.2 supports the following components:
    • An analysis cluster can contain the following components: Presto, Hadoop, Spark, HBase, OpenTSDB, Hive, Hue, Loader, Tez, Flink, Alluxio, and Ranger.
    • A streaming cluster can contain the following components: Kafka, KafkaManager, Storm, and Flume.

Constraints

None

Debugging

You can debug this API in API Explorer, which supports automatic authentication and authorization. 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, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependency

    mrs:cluster:createCluster

    Write

    cluster *

    -

    • mrs:cluster:create
    • iam:agencies:pass
    • ecs:cloudServers:createServers
    • ecs:cloudServers:deleteServers
    • ecs:cloudServerQuotas:get
    • ecs:cloudServerFlavors:get
    • ecs:cloudServers:listServersDetails
    • ecs:cloudServers:showServerGroup
    • ecs:cloudServers:updateMetadata
    • ecs:cloudServers:start
    • ecs:cloudServers:stop
    • ecs:serverGroups:manage
    • ecs:cloudServers:listServerInterfaces
    • vpc:vpcs:list
    • vpc:vpcs:create
    • eip:publicIps:list
    • eip:publicIps:get
    • vpc:ports:get
    • vpc:ports:create
    • vpc:ports:delete
    • vpc:ports:update
    • vpc:privateIps:create
    • vpc:privateIps:delete
    • vpc:securityGroups:get
    • vpc:securityGroups:create
    • vpc:securityGroups:delete
    • vpc:securityGroupRules:create
    • vpc:securityGroupRules:delete
    • vpc:quotas:list
    • evs:quotas:get
    • evs:types:get
    • rds:instance:get
    • rds:instance:listAll
    • kms:cmk:list
    • vpc:floatingIps:get
    • bms:serverQuotas:get
    • bms:serverFlavors:get
    • bms:servers:start
    • bms:servers:stop
    • bms:servers:create
    • bms:servers:updateMetadata
    • bms:servers:showBaremetalServer
    • bms:servers:list

    -

    • g:RequestTag/<tag-key>

    • g:TagKeys

    • g:EnterpriseProjectId

URI

POST /v2/{project_id}/clusters
Table 2 URI parameter

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

Request Parameters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

is_dec_project

No

Boolean

Definition

Whether the resource is a DeC resource, that is, whether the cluster is a DeC cluster.

Constraints

N/A

Range

  • true: The resource is a DeC resource.

  • false: The resource is not a DeC resource.

Default Value

false

cluster_version

Yes

String

Definition

Cluster version, for example, MRS 3.1.0. To see all supported cluster versions, click Buy Cluster on the MRS management console.

Constraints

N/A

Range

N/A

Default Value

N/A

cluster_name

Yes

String

Definition

Cluster name.

Constraints

N/A

Range

  • The name must be different from existing cluster names.

  • The value can contain 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Default Value

N/A

cluster_type

Yes

String

Definition

Cluster type.

Constraints

N/A

Range

  • ANALYSIS: analysis cluster
  • STREAMING: streaming cluster
  • MIXED: hybrid cluster
  • CUSTOM: custom cluster, which is supported only by MRS 3.x.

Default Value

N/A

charge_info

No

object

Definition

The billing type. For details, see Table 8.

Constraints

N/A

Range

N/A

Default Value

N/A

region

Yes

String

Definition

Information about the region where the cluster is located. For details, see Endpoints.

Constraints

N/A

Range

N/A

Default Value

N/A

vpc_name

Yes

String

Definition

Name of the VPC where the subnet locates. Perform the following operations to obtain the VPC name from the VPC management console:

  1. Log in to the management console.
  2. Choose Virtual Private Cloud > My VPCs. On the Virtual Private Cloud page, obtain the VPC name from the list.

Constraints

N/A

Range

N/A

Default Value

N/A

subnet_id

No

String

Definition

Subnet ID, which can be obtained by performing the following operations on the VPC management console:

  1. Log in to the VPC management console.
  2. Choose Virtual Private Cloud > My VPCs.
  3. Locate the row that contains the target VPC and click the number in the Subnets column to view the subnet information.
  4. Click the subnet name to obtain the network ID.

Constraints

At least one of subnet_id and subnet_name must be configured. If the two parameters are configured but do not match the same subnet, the cluster fails to create. subnet_id is recommended.

Range

N/A

Default Value

N/A

subnet_name

Yes

String

Definition

Subnet name. Perform the following operations to obtain the subnet name from the VPC management console:

  1. Log in to the management console.
  2. Choose Virtual Private Cloud > My VPCs.
  3. Locate the row that contains the target VPC and click the number in the Subnets column to obtain the subnet name.

Constraints

At least one of subnet_id and subnet_name must be configured. If the two parameters are configured but do not match the same subnet, the cluster fails to create. If only subnet_name is configured and subnets with the same name exist in the VPC, the first subnet name in the VPC is used when a cluster is created. subnet_id is recommended.

Range

N/A

Default Value

N/A

components

Yes

String

Definition

List of component names, which are separated by commas (,). For details about the component names, see the component list of each version in Table 1.

Constraints

N/A

Range

N/A

Default Value

N/A

external_datasources

No

Array of ClusterDataConnectorMap objects

Definition

When deploying components such as Hive and Ranger, you can associate data connections and store metadata in associated databases. For details about the parameters, see Table 4.

Constraints

N/A

Range

N/A

Default Value

N/A

availability_zone

Yes

String

Definition

AZ name. Multi-AZ clusters are not supported.

See Endpoints for details about AZs.

Constraints

N/A

Range

N/A

Default Value

N/A

security_groups_id

No

String

Definition

Security group ID of the cluster.

  • If this parameter is left blank, MRS automatically creates a security group, whose name starts with mrs_{cluster_name}.
  • If this parameter is specified, a fixed security group is used to create a cluster. The passed ID must be the security group ID in the current tenant.
  • Multiple security group IDs are supported and separated by commas (,).

Constraints

N/A

Range

N/A

Default Value

N/A

auto_create_default_security_group

No

Boolean

Definition

Whether to create the default security group for the MRS cluster.

Constraints

If this parameter is set to true, the default security group will be created for the cluster regardless of whether security_groups_id is specified.

Range

  • true: The default security group is created for the MRS cluster.
  • false: The default security group is not created.

Default Value

false

safe_mode

Yes

String

Definition

Run mode of an MRS cluster.

Constraints

N/A

Range

  • SIMPLE: normal cluster. In a normal cluster, Kerberos authentication is disabled, and users can use all functions provided by the cluster.
  • KERBEROS: security cluster. In a security cluster, Kerberos authentication is enabled, and common users cannot use the file management and job management functions of an MRS cluster or view cluster resource usage and the job records of Hadoop and Spark. To use more functions, the users must obtain the relevant permissions from the Manager administrator.

Default Value

N/A

manager_admin_password

Yes

String

Definition

Password of the MRS Manager administrator.

Constraints

N/A

Range
  • Must contain 8 to 26 characters.
  • Must contain at least four of the following: uppercase letters, lowercase letters, digits, and special characters (!@$%^-_=+[{}]:,./?), but must not contain spaces.
  • Cannot be the username or the username spelled backwards.

Default Value

N/A

login_mode

Yes

String

Definition

Node login mode.

Constraints

N/A

Range

  • PASSWORD: password-based login. If this value is selected, node_root_password cannot be left blank.
  • KEYPAIR: specifies the key pair used for login. If this value is selected, node_keypair_name cannot be left blank.

Default Value

N/A

node_root_password

No

String

Definition

Password of user root for logging in to a cluster node.

Constraints

N/A

Range

A password must meet the following requirements:
  • Must be 8 to 26 characters long.
  • Must contain at least four of the following: uppercase letters, lowercase letters, digits, and special characters (!@$%^-_=+[{}]:,./?), but must not contain spaces.
  • Cannot be the username or the username spelled backwards.

Default Value

N/A

node_keypair_name

No

String

Definition

Name of a key pair You can use a key pair to log in to the Master node in the cluster.

Constraints

N/A

Range

N/A

Default Value

N/A

enterprise_project_id

No

String

Definition

Enterprise project ID.

When you create a cluster, associate the enterprise project ID with the cluster.

The default value is 0, indicating the default enterprise project.

To obtain the enterprise project ID, see the id value in the enterprise_project field data structure table in section Querying the Enterprise Project List of the Enterprise Management API Reference.

Constraints

N/A

Range

N/A

Default Value

The default value is 0, indicating the default enterprise project.

eip_address

No

String

Definition

An EIP bound to an MRS cluster can be used to access MRS Manager. The EIP must have been created and must be in the same region as the cluster.

Constraints

N/A

Range

N/A

Default Value

N/A

eip_id

No

String

Definition

ID of the bound EIP. This parameter is mandatory when eip_address is configured. To obtain the EIP ID, log in to the VPC console, choose Network > Elastic IP and Bandwidth > Elastic IP, click the EIP to be bound, and obtain the ID in the Basic Information area.

Constraints

N/A

Range

N/A

Default Value

N/A

mrs_ecs_default_agency

No

String

Definition

Name of the agency bound to a cluster node by default. The value is fixed to MRS_ECS_DEFAULT_AGENCY.

An agency allows ECS or BMS to manage MRS resources. You can configure an agency of the ECS type to automatically obtain the AK/SK to access OBS.

The MRS_ECS_DEFAULT_AGENCY agency has the OBS OperateAccess permission of OBS and the CES FullAccess (for users who have enabled fine-grained policies), CES Administrator, and KMS Administrator permissions in the region where the cluster is located.

Constraints

N/A

Range

N/A

Default Value

N/A

template_id

No

String

Definition

Template used for node deployment when the cluster type is CUSTOM.

  • mgmt_control_combined_v2: template for jointly deploying the management and control nodes. The management and control roles are co-deployed on the Master node, and data instances are deployed in the same node group. This deployment mode applies to scenarios where the number of control nodes is less than 100, reducing costs.
  • mgmt_control_separated_v2: The management and control roles are deployed on different master nodes, and data instances are deployed in the same node group. This deployment mode is applicable to a cluster with 100 to 500 nodes and delivers better performance in high-concurrency load scenarios.
  • mgmt_control_data_separated_v2: The management role and control role are deployed on different Master nodes, and data instances are deployed in different node groups. This deployment mode is applicable to a cluster with more than 500 nodes. Components can be deployed separately, which can be used for a larger cluster scale.

Constraints

N/A

Range

N/A

Default Value

N/A

tags

No

Array of tag objects

Definition

Cluster tag For more parameter description, see Table 5.

Constraints

A cluster allows a maximum of 10 tags. A tag name (key) must be unique in a cluster.

Range

N/A

Default Value

N/A

log_collection

No

Integer

Definition

Whether to collect logs when cluster creation fails.

Constraints

N/A

Range

  • 0: Do not create an OBS bucket only for log collection when a cluster fails to be created.
  • 1: Create an OBS bucket only for collect logs when a cluster fails to be created.

Default Value

1

node_groups

Yes

Array of NodeGroupV2 objects

Definition

Information about the node groups in the cluster. For details about the parameters, see Table 6.

Constraints

N/A

Range

N/A

Default Value

N/A

bootstrap_scripts

No

Array of BootstrapScript objects

Definition

Bootstrap action script information. For more parameter description, see Table 14.

MRS 3.x does not support this parameter.

Constraints

N/A

Range

N/A

Default Value

N/A

add_jobs

No

Array of add_jobs objects

Definition

You can submit a job when creating a cluster. Currently, only versions earlier than MRS 1.8.7 support this function. Currently, only one job can be submitted. You are advised to use the steps parameter in the Creating a Cluster and Submitting a Job API. For details about this parameter, see Table 15.

Constraints

There must be no more than 1 record.

Range

N/A

Default Value

N/A

log_uri

No

String

Definition

The OBS path to which cluster logs are dumped. After the log dump function is enabled, the read and write permissions on the OBS path are required for uploading logs. Configure the default agency MRS_ECS_DEFAULT_AGENCY or customize an agency with the read and write permissions on the OBS path. For details, see Configuring a Storage-Compute Decoupled Cluster (Agency). This parameter is available only for cluster versions that support dumping cluster logs to OBS.

Constraints

N/A

Range

N/A

Default Value

N/A

component_configs

No

Array of ComponentConfig objects

Definition

The custom configuration of cluster components. This parameter applies only to cluster versions that support the feature of creating a cluster by customizing component configurations. For details about this parameter, see ComponentConfig.

Constraints

The number of records cannot exceed 50.

Range

N/A

Default Value

N/A

smn_notify

No

SmnNotify object

Definition

SMN alarm notifications. For details about this parameter, see Table 18.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 ClusterDataConnectorMap

Parameter

Mandatory

Type

Description

map_id

No

Integer

Definition

Data connection association ID

Constraints

N/A

Range

N/A

Default Value

N/A

connector_id

No

String

Definition

Data connection ID, which can be obtained on the data connection page of the MRS management console or by calling the API for listing data connections.

Constraints

N/A

Range

N/A

Default Value

N/A

component_name

No

String

Definition

Component name

Constraints

N/A

Range

N/A

Default Value

N/A

role_type

No

String

Definition

Component role type.

Constraints

N/A

Range

  • hive_metastore: Hive Metastore role
  • hive_data: Hive role
  • hbase_data: HBase role.
  • ranger_data: Ranger role

Default Value

N/A

source_type

No

String

Definition

Data connection type.

Constraints

N/A

Range

  • LOCAL_DB: local metadata
  • RDS_POSTGRES: RDS PostgreSQL database
  • RDS_MYSQL: RDS MySQL database
  • gaussdb-mysql: TaurusDB

Default Value

N/A

cluster_id

No

String

Definition

ID of the associated cluster

Constraints

N/A

Range

The value can contain 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Default Value

N/A

status

No

Integer

Definition

Data connection status.

Constraints

N/A

Range

  • 0: Normal.
  • 1: In use.

Default Value

N/A

Table 5 Tag parameters

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Tag key.

Constraints

N/A

Range

  • A tag key can contain letters, digits, spaces, and special characters _.:=+-@, but cannot start or end with a space or start with _sys_.
  • The tag key of a resource must be unique.
  • It can contain a maximum of 128 Unicode characters and cannot be an empty string.

Default Value

N/A

value

Yes

String

Definition

Tag value.

Constraints

N/A

Range

  • The value can contain letters, digits, spaces, and special characters _.:=+-@, but cannot start or end with a space or start with _sys_.
  • The value can contain a maximum of 255 Unicode characters and can be an empty string.

Default Value

N/A

Table 6 NodeGroup parameters

Parameter

Mandatory

Type

Description

group_name

Yes

String

Definition

Node group name.

Constraints

N/A

Range

The value can contain a maximum of 64 characters, including uppercase and lowercase letters, digits and underscores (_). The rules for configuring node groups are as follows:

  • master_node_default_group: master node group, which must be included in all cluster types.
  • core_node_analysis_group: analysis core node group, which must be included in both analysis and hybrid clusters.
  • core_node_streaming_group: streaming core node group, which must be included in both streaming and hybrid clusters.
  • task_node_analysis_group: analysis task node group, which can be selected for analysis clusters and hybrid clusters as needed.
  • task_node_streaming_group: streaming task node group, which can be selected for streaming clusters and hybrid clusters as needed.
  • node_group{x}: node group of a custom cluster. A maximum of nine such node groups can be added for a custom cluster.

Default Value

N/A

node_num

Yes

Integer

Definition

Number of nodes.

Constraints

The total number of Core and Task nodes cannot exceed 500.

Range

0-500

Default Value

N/A

node_size

Yes

String

Definition

Instance specification of the node. For example: {ECS_FLAVOR_NAME}.linux.bigdata, where {ECS_FLAVOR_NAME} can be c3.4xlarge.4 or other ECS specifications visible on the MRS purchase page.

For detailed information about instance specifications, see ECS Specifications Used by MRS and BMS Specifications Used by MRS.

You are advised to obtain the supported specifications for the corresponding region and version from the cluster creation page of the MRS console.

Constraints

N/A

Range

N/A

Default Value

N/A

root_volume

No

Volume object

Definition

System disk information of the node. This parameter is optional for some VMs or the system disk of the BMS. This parameter is mandatory in other cases. For details about the parameter description, see Table 7.

Constraints

N/A

Range

N/A

Default Value

N/A

data_volume

No

Volume object

Definition

Data disk information

Constraints

This parameter is mandatory when data_volume_count is not 0. For details about this parameter, see Table 7.

Range

N/A

Default Value

N/A

data_volume_count

No

Integer

Definition

Number of data disks of a node.

Constraints

N/A

Range

0-20

Default Value

N/A

charge_info

No

ChargeInfo object

Definition

The billing type of a node group. The billing types of master and core node groups are the same as those of the cluster. The billing type of the task node group can be different. For details about the parameters, see Table 8.

Constraints

N/A

Range

N/A

Default Value

N/A

auto_scaling_policy

No

auto_scaling_policy object

Definition

Autoscaling rule corresponding to the node group. For details about the parameters, see Table 9.

Constraints

N/A

Range

N/A

Default Value

N/A

assigned_roles

No

Array of strings

Definition

This parameter is mandatory when the cluster type is CUSTOM. You can specify the roles deployed in a node group. This parameter is a character string array. Each character string represents a role expression.

Role expression definition:

  • If the role is deployed on all nodes in the node group, set this parameter to <role name>, for example, DataNode.
  • If the role is deployed on a specified subscript node in the node group: <role name>:<index1>,<index2>..., <indexN>, for example, NameNode:1,2. The subscript starts from 1.

For details about available roles, see Roles and components supported by MRS.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 7 Volume

Parameter

Mandatory

Type

Description

type

Yes

String

Definition

Disk type.

Constraints

N/A

Range

  • SATA: common I/O disk
  • SAS: high I/O disk
  • SSD: ultra-high I/O disk
  • GPSSD: general-purpose SSD disk

Default Value

N/A

size

Yes

Integer

Definition

Data disk size in GB.

Constraints

N/A

Range

10-32768

Default Value

N/A

Table 8 ChargeInfo

Parameter

Mandatory

Type

Description

charge_mode

Yes

String

Definition

Billing mode.

Constraints

N/A

Range

  • prePaid: indicates the yearly/monthly billing mode. (This mode is now supported for the API for creating a cluster, but is not supported for the API for creating a cluster and submitting a job.)
  • postPaid: indicates the pay-per-use billing mode.

Default Value

N/A

period_type

No

String

Definition

Period type.

Constraints

N/A

Range

  • month: The cluster is billed by month.
  • year: The cluster is billed by year.
  • day: The cluster is billed on a pay-per-use basis.

Default Value

N/A

period_num

No

Integer

Definition

Number of periods.

Constraints

This parameter is valid and mandatory only when charge_mode is set to prePaid.

Range

  • If period_type is set to month, the value ranges from 1 to 9.
  • If period_type is set to year, the value ranges from 1 to 3.

Default Value

N/A

is_auto_pay

No

Boolean

Definition

Whether the order will be automatically paid. This parameter is available for yearly/monthly mode. By default, the automatic payment is disabled.

Constraints

N/A

Range

  • true: The system automatically selects available discounts and coupons, and then pays for the order with the account balances. If the automatic payment fails, an order in Pending payment state is generated waiting for manual payment.
  • false: The user needs to pay for the bill after using available discounts and coupons.

Default Value

N/A

Table 9 auto_scaling_policy parameters

Parameter

Mandatory

Type

Description

auto_scaling_enable

Yes

Boolean

Definition

Whether to enable the auto scaling rule.

Constraints

N/A

Range

  • true: Enable the auto scaling rule.
  • false: Disable the autoscaling rule.

Default Value

N/A

min_capacity

Yes

Integer

Definition

Minimum number of nodes left in the node group.

Constraints

N/A

Range

0-500

Default Value

N/A

max_capacity

Yes

Integer

Definition

Maximum number of nodes in the node group.

Constraints

N/A

Range

0-500

Default Value

N/A

resources_plans

No

Array of resources_plan objects

Definition

Resource plan list. For details, see Table 10. If this parameter is left blank, the resource plan is disabled.

Constraints

When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured.

Range

N/A

Default Value

N/A

rules

No

Array of rules objects

Definition

List of auto scaling rules. For details, see Table 11.

Constraints

When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured. The number of records cannot exceed 10.

Range

N/A

Default Value

N/A

exec_scripts

No

Array of scale_script objects

Definition

List of custom scaling automation scripts. For details, see Table 13. If this parameter is left blank, a hook script is disabled. This parameter is not available in the V2 API for creating and updating autoscaling policies.

Constraints

The number of records cannot exceed 10.

Range

N/A

Default Value

N/A

Table 10 ResourcesPlan

Parameter

Mandatory

Type

Description

period_type

Yes

String

Definition

Cycle type of a resource plan. This parameter can be set to daily only.

Constraints

N/A

Range

daily: Charges are calculated by day.

Default Value

N/A

start_time

Yes

String

Definition

The start time of a resource plan. The value is in the format of hour:minute, indicating that the time ranges from 00:00 to 23:59.

Constraints

N/A

Range

N/A

Default Value

N/A

end_time

Yes

String

Definition

End time of a resource plan. The format is the same as that of start_time.

Constraints

The value cannot be earlier than the start_time, and the interval between start_time and start_time cannot be less than 30 minutes.

Range

N/A

Default Value

N/A

min_capacity

Yes

Integer

Definition

Minimum number of the preserved nodes in a node group in a resource plan.

Constraints

N/A

Range

0-500

Default Value

N/A

max_capacity

Yes

Integer

Definition

Maximum number of the preserved nodes in a node group in a resource plan.

Constraints

N/A

Range

0-500

Default Value

N/A

effective_days

No

Array of strings

Definition

The effective date of a resource plan. If this parameter is left blank, it indicates that the resource plan takes effect every day. The options are as follows:

MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY

Constraints

N/A

Range

N/A

Default Value

N/A

Table 11 rules parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Name of an auto scaling rule.

Constraints

N/A

Range

The value can contain 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Rule names must be unique in a node group.

Default Value

N/A

description

No

String

Definition

Description about an auto scaling rule.

Constraints

N/A

Range

The value can contain 0 to 1024 characters.

Default Value

N/A

adjustment_type

Yes

String

Definition

Adjustment type of an auto scaling rule.

Constraints

N/A

Range

  • scale_out: cluster scale-out
  • scale_in: cluster scale-in

Default Value

N/A

cool_down_minutes

Yes

Integer

Definition

Cluster cooling time after an auto scaling rule is triggered, when no auto scaling operation is performed. The unit is minute.

Constraints

N/A

Range

The value ranges from 0 to 10080. 10080 indicates the number of minutes in a week.

Default Value

N/A

scaling_adjustment

Yes

Integer

Definition

Number of nodes that can be adjusted once.

Constraints

N/A

Range

1-100

Default Value

N/A

trigger

Yes

Trigger object

Definition

Condition for triggering a rule. For details, see Table 12.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 12 trigger parameters

Parameter

Mandatory

Type

Description

metric_name

Yes

String

Definition

Metric name. This triggering condition makes a judgment according to the value of the metric.

Constraints

N/A

Range

The value can contain 0 to 64 characters.

Default Value

N/A

metric_value

Yes

String

Definition

Metric threshold to trigger a rule. The value must be an integer or a number with two decimal places.

Constraints

N/A

Range

Only integers or numbers with two decimal places are allowed.

Default Value

N/A

comparison_operator

No

String

Definition

Metric judgment logic operator.

Constraints

N/A

Range

  • LT: less than
  • GT: greater than
  • LTOE: less than or equal to
  • GTOE: greater than or equal to

Default Value

N/A

evaluation_periods

Yes

Integer

Definition

Number of consecutive five-minute periods, during which a metric threshold is reached

Constraints

N/A

Range

1-288

Default Value

N/A

Table 13 scale_script parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Names of custom scaling automation scripts.

Constraints

N/A

Range

The names in the same cluster must be unique.

The value can contain only digits, letters, spaces, hyphens (-), and underscores (_) and must not start with a space.

The value can contain 1 to 64 characters.

Default Value

N/A

uri

Yes

String

Definition

Path of a custom automation script. Set this parameter to an OBS bucket path or a local VM path.

  • OBS bucket path: Enter a script path manually. For example, s3a://XXX/scale.sh.
  • Local VM path: Enter a script path. The script path must start with a slash (/) and end with .sh.

Constraints

N/A

Range

N/A

Default Value

N/A

parameters

No

String

Definition

Parameters of a custom automation script.

  • Multiple parameters are separated by space.
  • The following predefined system parameters can be transferred:
    • ${mrs_scale_node_num}: Number of the nodes to be added or removed
    • ${mrs_scale_type}: Scaling type. The value can be scale_out or scale_in.
    • ${mrs_scale_node_hostnames}: Host names of the nodes to be added or removed
    • ${mrs_scale_node_ips}: IP addresses of the nodes to be added or removed
    • ${mrs_scale_rule_name}: Name of the rule that triggers auto scaling
  • Other user-defined parameters are used in the same way as those of common shell scripts. Parameters are separated by space.

Constraints

N/A

Range

N/A

Default Value

N/A

nodes

Yes

List<String>

Definition

Type of a node where the custom automation script is executed. The node type can be Master, Core, or Task.

Constraints

N/A

Range

N/A

Default Value

N/A

active_master

No

Boolean

Definition

Whether the custom automation script runs only on the active master node.

Constraints

N/A

Range

  • true: The custom automation script runs only on the active Master nodes.
  • false: The custom automation script can run on all Master nodes.

Default Value

false

fail_action

Yes

String

Definition

Whether to continue to execute subsequent scripts and create a cluster after the custom automation script fails to be executed. You are advised to set this parameter to continue in the commissioning phase so the cluster can continue to be installed and started no matter whether the custom automation script is executed successfully.

Constraints

The scale-in operation cannot be undone. fail_action must be set to continue for the scripts that are executed after scale-in.

Range

  • continue: Continue to execute subsequent scripts.
  • errorout: Stop the action.

Default Value

N/A

action_stage

Yes

String

Definition

Time when a script is executed.

Constraints

N/A

Range

  • before_scale_out: before scale-out
  • before_scale_in: before scale-in
  • after_scale_out: after scale-out
  • after_scale_in: after scale-in

Default Value

N/A

Table 14 BootstrapScript

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Name of a bootstrap action script.

Constraints

N/A

Range

The names of bootstrap action scripts in the same cluster must be unique.

The value can contain only digits, letters, spaces, hyphens (-), and underscores (_) and must not start with a space.

The value can contain 1 to 64 characters.

Default Value

N/A

uri

Yes

String

Definition

Path of a bootstrap action script. Set this parameter to an OBS bucket path or a local VM path.

  • OBS bucket path: Enter a script path manually. For example, enter the path of the public sample script provided by MRS. Example: s3a://bootstrap/presto/presto-install.sh. If dualroles is installed, the parameter of the presto-install.sh script is dualroles. If worker is installed, the parameter of the presto-install.sh script is worker. Based on the Presto usage habit, you are advised to install dualroles on the active master nodes and worker on the Core nodes.
  • Local VM path: Enter a script path. The script path must start with a slash (/) and end with .sh.

Constraints

N/A

Range

N/A

Default Value

N/A

parameters

No

String

Definition

Bootstrap action script parameters

Constraints

N/A

Range

N/A

Default Value

N/A

nodes

Yes

Array of strings

Definition

Name of the node group where the bootstrap action script is executed

Constraints

N/A

Range

N/A

Default Value

N/A

active_master

No

Boolean

Definition

Whether the bootstrap action script runs only on active Master nodes.

Constraints

N/A

Range

  • true: The bootstrap action script runs only on active Master nodes.
  • false: The bootstrap action script can run on all Master nodes.

Default Value

N/A

before_component_start

No

Boolean

Definition

Time when the bootstrap action script is executed. Currently, the following two options are available: Before component start and After component start

Constraints

N/A

Range

  • true: The bootstrap action script is executed before the component starts.
  • false: The bootstrap action script is executed after the component starts.

Default Value

false

fail_action

Yes

String

Definition

Whether to continue executing subsequent scripts and creating a cluster after the bootstrap action script fails to be executed. You are advised to set this parameter to continue in the commissioning phase so that the cluster can continue to be installed and started no matter whether the bootstrap action is successful.

Constraints

N/A

Range

  • continue: Continue to execute subsequent scripts.
  • errorout: Stop the action.

Default Value

N/A

start_time

No

Long

Definition

Execution time for a single bootstrap action script. The value is a Unix timestamp in seconds.

Constraints

N/A

Range

N/A

Default Value

N/A

state

No

String

Definition

The running status of one bootstrap action script.

Constraints

N/A

Range

  • PENDING: The script is suspended.
  • IN_PROGRESS: The script is being processed.
  • SUCCESS: The script is successfully executed.
  • FAILURE: The script fails to be executed.

Default Value

N/A

action_stages

No

Array of strings

Definition

Select the time when the bootstrap action script is executed.

Constraints

Enumerated values:

  • BEFORE_COMPONENT_FIRST_START: Before a component is started for the first time.
  • AFTER_COMPONENT_FIRST_START: After a component is started for the first time.
  • BEFORE_SCALE_IN: Before cluster node scale-in.
  • AFTER_SCALE_IN: After cluster node scale-in.
  • BEFORE_SCALE_OUT: Before cluster node scale-out.
  • AFTER_SCALE_OUT: After cluster node scale-out.

Range

N/A

Default Value

N/A

Table 15 add_jobs parameters

Parameter

Mandatory

Type

Description

job_type

Yes

Integer

Definition

Job type code

Constraints

N/A

Range

  • 1: MapReduce job.

  • 2: Spark job.

  • 3: Hive Script job.

  • 4: HiveSQL job (currently not supported).

  • 5: DistCp job, used for efficiently importing and exporting data between distributed file systems (such as HDFS) (currently not supported).

  • 6: Spark Script job.

  • 7: Spark SQL job (currently not supported).

Default Value

N/A

job_name

Yes

String

Definition

Job name

Constraints

N/A

Range

The name can contain 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Identical job names are allowed but not recommended.

Default Value

N/A

jar_path

No

String

Definition

Path of the .jar file or .sql file to be executed.

Constraints

N/A

Range

  • Contains a maximum of 1023 characters, excluding special characters such as ;|&><'$. The parameter value cannot be empty or full of spaces.
  • Files can be stored in HDFS or OBS. The path varies depending on the file system.
    • OBS: The path must start with s3a://. Files or programs encrypted by KMS are not supported.
    • HDFS: The path starts with a slash (/).
  • Spark Script must end with .sql while MapReduce and Spark Jar must end with .jar. sql and jar are case-insensitive.

Default Value

N/A

arguments

No

String

Definition

Key parameter for program execution. The parameter is specified by the function of the user's program. MRS is only responsible for loading the parameter.

Constraints

N/A

Range

The parameter can contain 0 to 150,000 characters, but special characters (;|&>'<$) are not allowed.

Default Value

N/A

input

No

String

Definition

Address for inputting data.

Files can be stored in HDFS or OBS. The path varies depending on the file system.
  • OBS: The path must start with s3a://. Files or programs encrypted by KMS are not supported.
  • HDFS: The path starts with a slash (/).

Constraints

N/A

Range

The parameter contains a maximum of 1023 characters, excluding special characters such as ;|&>'<$, and can be left blank.

Default Value

N/A

output

No

String

Definition

Address for outputting data.

Files can be stored in HDFS or OBS. The path varies depending on the file system.
  • OBS: The path must start with s3a://.
  • HDFS: The path starts with a slash (/).

If the specified path does not exist, the system will automatically create it.

Constraints

N/A

Range

The parameter contains a maximum of 1023 characters, excluding special characters such as ;|&>'<$, and can be left blank.

Default Value

N/A

job_log

No

String

Definition

Path for storing job logs that record job running status.

Files can be stored in HDFS or OBS. The path varies depending on the file system.
  • OBS: The path must start with s3a://.
  • HDFS: The path starts with a slash (/).

Constraints

N/A

Range

The parameter contains a maximum of 1023 characters, excluding special characters such as ;|&>'<$, and can be left blank.

Default Value

N/A

shutdown_cluster

No

Boolean

Definition

Whether to delete the cluster after the job execution is complete.

Constraints

N/A

Range

  • true: Delete the cluster.
  • false: Do not delete the cluster.

Default Value

N/A

file_action

No

String

Definition

The action to be performed on a file.

Constraints

N/A

Range

  • import: Import data.
  • export: Export data.

Default Value

N/A

submit_job_once_cluster_run

Yes

Boolean

Definition

Whether to submit a job when creating a cluster. Set this parameter to true in this example.

Constraints

N/A

Range

  • true: Submit a job during cluster creation.
  • false: Submit a job after the cluster is created.

Default Value

N/A

hql

No

String

Definition

HiveQL statement

Constraints

N/A

Range

N/A

Default Value

N/A

hive_script_path

No

String

Definition

SQL program path. This parameter is needed by Spark Script and Hive Script jobs only,

Constraints

N/A

Range

  • Contains a maximum of 1023 characters, excluding special characters such as ;|&><'$. The address cannot be empty or full of spaces.
  • Files can be stored in HDFS or OBS. The path varies depending on the file system.
    • OBS: The path must start with s3a://. Files or programs encrypted by KMS are not supported.
    • HDFS: The path starts with a slash (/).
  • Ends with .sql. sql is case-insensitive.

Default Value

N/A

Table 16 ComponentConfig

Parameter

Mandatory

Type

Description

component_name

Yes

String

Definition

Component name

Constraints

N/A

Range

N/A

Default Value

N/A

configs

No

Array of Config objects

Definition

The component configuration item list. For details about this parameter, see Table 17.

Constraints

The number of records cannot exceed 100.

Range

N/A

Default Value

N/A

Table 17 Config

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

The configuration name. Only the configuration names displayed on the MRS component configuration page are supported.

Constraints

N/A

Range

N/A

Default Value

N/A

value

Yes

String

Definition

Configuration value

Constraints

N/A

Range

N/A

Default Value

N/A

config_file_name

Yes

String

Definition

Configuration file name. Only the file names displayed on the MRS component configuration page are supported.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 18 SmnNotify

Parameter

Mandatory

Type

Description

topic_urn

No

String

Definition

SMN topic URN.

Constraints

Mandatory if alarm subscription needs to be enabled.

Range

N/A

Default Value

N/A

subscription_name

No

String

Definition

Subscription rule name

Constraints

N/A

Range

N/A

Default Value

default_alert_rule

Response Parameters

Status code: 200

Table 19 Response parameters

Parameter

Type

Description

cluster_id

String

Definition

Cluster ID, which is returned by the system after the cluster is created.

Range

N/A

Example Request

  • Create an analysis cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with three nodes. Autoscaling is enabled every Monday from 12:00 to 13:00. The initial configuration hive.union.data.type.incompatible.enable of the Hive component is changed to true, and dfs.replication is changed to 4.
    POST /v2/{project_id}/clusters
    
    {
      "cluster_version" : "MRS 3.1.0",
      "cluster_name" : "mrs_DyJA_dm",
      "cluster_type" : "ANALYSIS",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "region" : "",
      "availability_zone" : "",
      "vpc_name" : "vpc-37cd",
      "subnet_id" : "1f8c5ca6-1f66-4096-bb00-baf175954f6e",
      "subnet_name" : "subnet",
      "components" : "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Flink,Oozie,Ranger,Tez",
      "safe_mode" : "KERBEROS",
      "manager_admin_password" : "your password",
      "login_mode" : "PASSWORD",
      "node_root_password" : "your password",
      "log_collection" : 1,
      "mrs_ecs_default_agency" : "MRS_ECS_DEFAULT_AGENCY",
      "tags" : [ {
        "key" : "tag1",
        "value" : "111"
      }, {
        "key" : "tag2",
        "value" : "222"
      } ],
      "node_groups" : [ {
        "group_name" : "master_node_default_group",
        "node_num" : 2,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "core_node_analysis_group",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "task_node_analysis_group",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "auto_scaling_policy" : {
          "auto_scaling_enable" : true,
          "min_capacity" : 0,
          "max_capacity" : 1,
          "resources_plans" : [ {
            "period_type" : "daily",
            "start_time" : "12:00",
            "end_time" : "13:00",
            "min_capacity" : 2,
            "max_capacity" : 3,
            "effective_days" : [ "MONDAY" ]
          } ],
          "exec_scripts" : [ {
            "name" : "test",
            "uri" : "s3a://obs-mrstest/bootstrap/basic_success.sh",
            "parameters" : "",
            "nodes" : [ "master_node_default_group", "core_node_analysis_group", "task_node_analysis_group" ],
            "active_master" : false,
            "action_stage" : "before_scale_out",
            "fail_action" : "continue"
          } ],
          "rules" : [ {
            "name" : "default-expand-1",
            "description" : "",
            "adjustment_type" : "scale_out",
            "cool_down_minutes" : 5,
            "scaling_adjustment" : 1,
            "trigger" : {
              "metric_name" : "YARNAppRunning",
              "metric_value" : "100",
              "comparison_operator" : "GTOE",
              "evaluation_periods" : 1
            }
          } ]
        }
      } ],
      "component_configs" : [ {
        "component_name" : "Hive",
        "configs" : [ {
          "key" : "hive.union.data.type.incompatible.enable",
          "value" : "true",
          "config_file_name" : "hive-site.xml"
        }, {
          "key" : "dfs.replication",
          "value" : "4",
          "config_file_name" : "hdfs-site.xml"
        } ]
      } ]
    }
  • Create a streaming cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with zero nodes. Autoscaling is enabled every Monday from 12:00 to 13:00.
    POST /v2/{project_id}/clusters
    
    {
      "cluster_version" : "MRS 3.1.0",
      "cluster_name" : "mrs_Dokle_dm",
      "cluster_type" : "STREAMING",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "region" : "",
      "availability_zone" : "",
      "vpc_name" : "vpc-37cd",
      "subnet_id" : "1f8c5ca6-1f66-4096-bb00-baf175954f6e",
      "subnet_name" : "subnet",
      "components" : "Storm,Kafka,Flume,Ranger",
      "safe_mode" : "KERBEROS",
      "manager_admin_password" : "your password",
      "login_mode" : "PASSWORD",
      "node_root_password" : "your password",
      "log_collection" : 1,
      "mrs_ecs_default_agency" : "MRS_ECS_DEFAULT_AGENCY",
      "tags" : [ {
        "key" : "tag1",
        "value" : "111"
      }, {
        "key" : "tag2",
        "value" : "222"
      } ],
      "node_groups" : [ {
        "group_name" : "master_node_default_group",
        "node_num" : 2,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "core_node_streaming_group",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "task_node_streaming_group",
        "node_num" : 0,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "auto_scaling_policy" : {
          "auto_scaling_enable" : true,
          "min_capacity" : 0,
          "max_capacity" : 1,
          "resources_plans" : [ {
            "period_type" : "daily",
            "start_time" : "12:00",
            "end_time" : "13:00",
            "min_capacity" : 2,
            "max_capacity" : 3,
            "effective_days" : [ "MONDAY" ]
          } ],
          "rules" : [ {
            "name" : "default-expand-1",
            "description" : "",
            "adjustment_type" : "scale_out",
            "cool_down_minutes" : 5,
            "scaling_adjustment" : 1,
            "trigger" : {
              "metric_name" : "StormSlotAvailablePercentage",
              "metric_value" : "100",
              "comparison_operator" : "LTOE",
              "evaluation_periods" : 1
            }
          } ]
        }
      } ]
    }
  • Create a hybrid cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, two Core node groups with three nodes each, and two Task node groups — one with one node and the other with zero nodes.
    POST /v2/{project_id}/clusters
    
    {
      "cluster_version" : "MRS 3.1.0",
      "cluster_name" : "mrs_onmm_dm",
      "cluster_type" : "MIXED",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "region" : "",
      "availability_zone" : "",
      "vpc_name" : "vpc-37cd",
      "subnet_id" : "1f8c5ca6-1f66-4096-bb00-baf175954f6e",
      "subnet_name" : "subnet",
      "components" : "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
      "safe_mode" : "KERBEROS",
      "manager_admin_password" : "your password",
      "login_mode" : "PASSWORD",
      "node_root_password" : "your password",
      "log_collection" : 1,
      "mrs_ecs_default_agency" : "MRS_ECS_DEFAULT_AGENCY",
      "tags" : [ {
        "key" : "tag1",
        "value" : "111"
      }, {
        "key" : "tag2",
        "value" : "222"
      } ],
      "node_groups" : [ {
        "group_name" : "master_node_default_group",
        "node_num" : 2,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "core_node_streaming_group",
        "node_num" : 3,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "core_node_analysis_group",
        "node_num" : 3,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "task_node_analysis_group",
        "node_num" : 1,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      }, {
        "group_name" : "task_node_streaming_group",
        "node_num" : 0,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1
      } ]
    }
  • Create a custom cluster where management and control nodes are co-located, with cluster version MRS 3.1.0. The cluster contains one Master node group with three nodes, and two Core node groups — one with three nodes and the other with one node.
    POST /v2/{project_id}/clusters
    
    {
      "cluster_version" : "MRS 3.1.0",
      "cluster_name" : "mrs_heshe_dm",
      "cluster_type" : "CUSTOM",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "region" : "",
      "availability_zone" : "",
      "vpc_name" : "vpc-37cd",
      "subnet_id" : "1f8c5ca6-1f66-4096-bb00-baf175954f6e",
      "subnet_name" : "subnet",
      "components" : "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
      "safe_mode" : "KERBEROS",
      "manager_admin_password" : "your password",
      "login_mode" : "PASSWORD",
      "node_root_password" : "your password",
      "mrs_ecs_default_agency" : "MRS_ECS_DEFAULT_AGENCY",
      "template_id" : "mgmt_control_combined_v2",
      "log_collection" : 1,
      "tags" : [ {
        "key" : "tag1",
        "value" : "111"
      }, {
        "key" : "tag2",
        "value" : "222"
      } ],
      "node_groups" : [ {
        "group_name" : "master_node_default_group",
        "node_num" : 3,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "OMSServer:1,2", "SlapdServer:1,2", "KerberosServer:1,2", "KerberosAdmin:1,2", "quorumpeer:1,2,3", "NameNode:2,3", "Zkfc:2,3", "JournalNode:1,2,3", "ResourceManager:2,3", "JobHistoryServer:2,3", "DBServer:1,3", "Hue:1,3", "LoaderServer:1,3", "MetaStore:1,2,3", "WebHCat:1,2,3", "HiveServer:1,2,3", "HMaster:2,3", "MonitorServer:1,2", "Nimbus:1,2", "UI:1,2", "JDBCServer2x:1,2,3", "JobHistory2x:2,3", "SparkResource2x:1,2,3", "oozie:2,3", "LoadBalancer:2,3", "TezUI:1,3", "TimelineServer:3", "RangerAdmin:1,2", "UserSync:2", "TagSync:2", "KerberosClient", "SlapdClient", "meta", "HSConsole:2,3", "FlinkResource:1,2,3", "DataNode:1,2,3", "NodeManager:1,2,3", "IndexServer2x:1,2", "ThriftServer:1,2,3", "RegionServer:1,2,3", "ThriftServer1:1,2,3", "RESTServer:1,2,3", "Broker:1,2,3", "Supervisor:1,2,3", "Logviewer:1,2,3", "Flume:1,2,3", "HSBroker:1,2,3" ]
      }, {
        "group_name" : "node_group_1",
        "node_num" : 3,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "DataNode", "NodeManager", "RegionServer", "Flume:1", "Broker", "Supervisor", "Logviewer", "HBaseIndexer", "KerberosClient", "SlapdClient", "meta", "HSBroker:1,2", "ThriftServer", "ThriftServer1", "RESTServer", "FlinkResource" ]
      }, {
        "group_name" : "node_group_2",
        "node_num" : 1,
        "node_size" : "Sit3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "NodeManager", "KerberosClient", "SlapdClient", "meta", "FlinkResource" ]
      } ]
    }
  • Create a custom cluster where management and control nodes are deployed separately, with cluster version MRS 3.1.0. The cluster contains one Master node group with five nodes and one Core node group with three nodes.
    POST /v2/{project_id}/clusters
    
    {
      "cluster_version" : "MRS 3.1.0",
      "cluster_name" : "mrs_jdRU_dm01",
      "cluster_type" : "CUSTOM",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "region" : "",
      "availability_zone" : "",
      "vpc_name" : "vpc-37cd",
      "subnet_id" : "1f8c5ca6-1f66-4096-bb00-baf175954f6e",
      "subnet_name" : "subnet",
      "components" : "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
      "safe_mode" : "KERBEROS",
      "manager_admin_password" : "your password",
      "login_mode" : "PASSWORD",
      "node_root_password" : "your password",
      "mrs_ecs_default_agency" : "MRS_ECS_DEFAULT_AGENCY",
      "log_collection" : 1,
      "template_id" : "mgmt_control_separated_v2",
      "tags" : [ {
        "key" : "aaa",
        "value" : "111"
      }, {
        "key" : "bbb",
        "value" : "222"
      } ],
      "node_groups" : [ {
        "group_name" : "master_node_default_group",
        "node_num" : 5,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "OMSServer:1,2", "SlapdServer:3,4", "KerberosServer:3,4", "KerberosAdmin:3,4", "quorumpeer:3,4,5", "NameNode:4,5", "Zkfc:4,5", "JournalNode:1,2,3,4,5", "ResourceManager:4,5", "JobHistoryServer:4,5", "DBServer:3,5", "Hue:1,2", "LoaderServer:1,2", "MetaStore:1,2,3,4,5", "WebHCat:1,2,3,4,5", "HiveServer:1,2,3,4,5", "HMaster:4,5", "MonitorServer:1,2", "Nimbus:1,2", "UI:1,2", "JDBCServer2x:1,2,3,4,5", "JobHistory2x:4,5", "SparkResource2x:1,2,3,4,5", "oozie:1,2", "LoadBalancer:1,2", "TezUI:1,2", "TimelineServer:5", "RangerAdmin:1,2", "KerberosClient", "SlapdClient", "meta", "HSConsole:1,2", "FlinkResource:1,2,3,4,5", "DataNode:1,2,3,4,5", "NodeManager:1,2,3,4,5", "IndexServer2x:1,2", "ThriftServer:1,2,3,4,5", "RegionServer:1,2,3,4,5", "ThriftServer1:1,2,3,4,5", "RESTServer:1,2,3,4,5", "Broker:1,2,3,4,5", "Supervisor:1,2,3,4,5", "Logviewer:1,2,3,4,5", "Flume:1,2,3,4,5", "HBaseIndexer:1,2,3,4,5", "TagSync:1", "UserSync:1" ]
      }, {
        "group_name" : "node_group_1",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "DataNode", "NodeManager", "RegionServer", "Flume:1", "Broker", "Supervisor", "Logviewer", "HBaseIndexer", "KerberosClient", "SlapdClient", "meta", "HSBroker:1,2", "ThriftServer", "ThriftServer1", "RESTServer", "FlinkResource" ]
      } ]
    }
  • Create a custom cluster where data nodes are deployed separately, with cluster version MRS 3.1.0. The cluster contains one Master node group with nine nodes and four Core node groups, each with three nodes.
    POST /v2/{project_id}/clusters
    
    {
      "cluster_version" : "MRS 3.1.0",
      "cluster_name" : "mrs_jdRU_dm02",
      "cluster_type" : "CUSTOM",
      "charge_info" : {
        "charge_mode" : "postPaid"
      },
      "region" : "",
      "availability_zone" : "",
      "vpc_name" : "vpc-37cd",
      "subnet_id" : "1f8c5ca6-1f66-4096-bb00-baf175954f6e",
      "subnet_name" : "subnet",
      "components" : "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
      "safe_mode" : "KERBEROS",
      "manager_admin_password" : "your password",
      "login_mode" : "PASSWORD",
      "node_root_password" : "your password",
      "mrs_ecs_default_agency" : "MRS_ECS_DEFAULT_AGENCY",
      "template_id" : "mgmt_control_data_separated_v2",
      "log_collection" : 1,
      "tags" : [ {
        "key" : "aaa",
        "value" : "111"
      }, {
        "key" : "bbb",
        "value" : "222"
      } ],
      "node_groups" : [ {
        "group_name" : "master_node_default_group",
        "node_num" : 9,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "OMSServer:1,2", "SlapdServer:5,6", "KerberosServer:5,6", "KerberosAdmin:5,6", "quorumpeer:5,6,7,8,9", "NameNode:3,4", "Zkfc:3,4", "JournalNode:5,6,7", "ResourceManager:8,9", "JobHistoryServer:8", "DBServer:8,9", "Hue:8,9", "FlinkResource:3,4", "LoaderServer:3,5", "MetaStore:8,9", "WebHCat:5", "HiveServer:8,9", "HMaster:8,9", "FTP-Server:3,4", "MonitorServer:3,4", "Nimbus:8,9", "UI:8,9", "JDBCServer2x:8,9", "JobHistory2x:8,9", "SparkResource2x:5,6,7", "oozie:4,5", "EsMaster:7,8,9", "LoadBalancer:8,9", "TezUI:5,6", "TimelineServer:5", "RangerAdmin:4,5", "UserSync:5", "TagSync:5", "KerberosClient", "SlapdClient", "meta", "HSBroker:5", "HSConsole:3,4", "FlinkResource:3,4" ]
      }, {
        "group_name" : "node_group_1",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "DataNode", "NodeManager", "RegionServer", "Flume:1", "GraphServer", "KerberosClient", "SlapdClient", "meta", "HSBroker:1,2" ]
      }, {
        "group_name" : "node_group_2",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "HBaseIndexer", "SolrServer[3]", "EsNode[2]", "KerberosClient", "SlapdClient", "meta", "SolrServerAdmin:1,2" ]
      }, {
        "group_name" : "node_group_3",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "KerberosClient", "SlapdClient", "meta" ]
      }, {
        "group_name" : "node_group_4",
        "node_num" : 3,
        "node_size" : "rc3.4xlarge.4.linux.bigdata",
        "root_volume" : {
          "type" : "SAS",
          "size" : 480
        },
        "data_volume" : {
          "type" : "SAS",
          "size" : 600
        },
        "data_volume_count" : 1,
        "assigned_roles" : [ "Broker", "Supervisor", "Logviewer", "KerberosClient", "SlapdClient", "meta" ]
      } ]
    }

Example Response

  • Example of a successful response

    Status code: 200

    Example response for a successful request

    {
      "cluster_id" : "da1592c2-bb7e-468d-9ac9-83246e95447a"
    }
  • Example of a failed response
    {
    	"error_code": "MRS.0002",
    	"error_msg": "The parameter is invalid."
    }

SDK Sample Code

The SDK sample code is as follows.

  • Create an analysis cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with three nodes. Autoscaling is enabled every Monday from 12:00 to 13:00. The initial configuration hive.union.data.type.incompatible.enable of the Hive component is changed to true, and dfs.replication is changed to 4.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    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 CreateClusterSolution {
    
        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();
            CreateClusterRequest request = new CreateClusterRequest();
            CreateClusterReqV2 body = new CreateClusterReqV2();
            List<Config> listComponentConfigsConfigs = new ArrayList<>();
            listComponentConfigsConfigs.add(
                new Config()
                    .withKey("hive.union.data.type.incompatible.enable")
                    .withValue("true")
                    .withConfigFileName("hive-site.xml")
            );
            listComponentConfigsConfigs.add(
                new Config()
                    .withKey("dfs.replication")
                    .withValue("4")
                    .withConfigFileName("hdfs-site.xml")
            );
            List<ComponentConfig> listbodyComponentConfigs = new ArrayList<>();
            listbodyComponentConfigs.add(
                new ComponentConfig()
                    .withComponentName("Hive")
                    .withConfigs(listComponentConfigsConfigs)
            );
            List<String> listExecScriptsNodes = new ArrayList<>();
            listExecScriptsNodes.add("master_node_default_group");
            listExecScriptsNodes.add("core_node_analysis_group");
            listExecScriptsNodes.add("task_node_analysis_group");
            List<ScaleScript> listAutoScalingPolicyExecScripts = new ArrayList<>();
            listAutoScalingPolicyExecScripts.add(
                new ScaleScript()
                    .withName("test")
                    .withUri("s3a://obs-mrstest/bootstrap/basic_success.sh")
                    .withParameters("")
                    .withNodes(listExecScriptsNodes)
                    .withActiveMaster(false)
                    .withFailAction(ScaleScript.FailActionEnum.fromValue("continue"))
                    .withActionStage(ScaleScript.ActionStageEnum.fromValue("before_scale_out"))
            );
            Trigger triggerRules = new Trigger();
            triggerRules.withMetricName("YARNAppRunning")
                .withMetricValue("100")
                .withComparisonOperator("GTOE")
                .withEvaluationPeriods(1);
            List<Rule> listAutoScalingPolicyRules = new ArrayList<>();
            listAutoScalingPolicyRules.add(
                new Rule()
                    .withName("default-expand-1")
                    .withDescription("")
                    .withAdjustmentType(Rule.AdjustmentTypeEnum.fromValue("scale_out"))
                    .withCoolDownMinutes(5)
                    .withScalingAdjustment(1)
                    .withTrigger(triggerRules)
            );
            List<ResourcesPlan.EffectiveDaysEnum> listResourcesPlansEffectiveDays = new ArrayList<>();
            listResourcesPlansEffectiveDays.add(ResourcesPlan.EffectiveDaysEnum.fromValue("MONDAY"));
            List<ResourcesPlan> listAutoScalingPolicyResourcesPlans = new ArrayList<>();
            listAutoScalingPolicyResourcesPlans.add(
                new ResourcesPlan()
                    .withPeriodType("daily")
                    .withStartTime("12:00")
                    .withEndTime("13:00")
                    .withMinCapacity(2)
                    .withMaxCapacity(3)
                    .withEffectiveDays(listResourcesPlansEffectiveDays)
            );
            AutoScalingPolicy autoScalingPolicyNodeGroups = new AutoScalingPolicy();
            autoScalingPolicyNodeGroups.withAutoScalingEnable(true)
                .withMinCapacity(0)
                .withMaxCapacity(1)
                .withResourcesPlans(listAutoScalingPolicyResourcesPlans)
                .withRules(listAutoScalingPolicyRules)
                .withExecScripts(listAutoScalingPolicyExecScripts);
            Volume dataVolumeNodeGroups = new Volume();
            dataVolumeNodeGroups.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups = new Volume();
            rootVolumeNodeGroups.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups1 = new Volume();
            dataVolumeNodeGroups1.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups1 = new Volume();
            rootVolumeNodeGroups1.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups2 = new Volume();
            dataVolumeNodeGroups2.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups2 = new Volume();
            rootVolumeNodeGroups2.withType("SAS")
                .withSize(480);
            List<NodeGroupV2> listbodyNodeGroups = new ArrayList<>();
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("master_node_default_group")
                    .withNodeNum(2)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups2)
                    .withDataVolume(dataVolumeNodeGroups2)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("core_node_analysis_group")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups1)
                    .withDataVolume(dataVolumeNodeGroups1)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("task_node_analysis_group")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups)
                    .withDataVolume(dataVolumeNodeGroups)
                    .withDataVolumeCount(1)
                    .withAutoScalingPolicy(autoScalingPolicyNodeGroups)
            );
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("tag1")
                    .withValue("111")
            );
            listbodyTags.add(
                new Tag()
                    .withKey("tag2")
                    .withValue("222")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            body.withComponentConfigs(listbodyComponentConfigs);
            body.withNodeGroups(listbodyNodeGroups);
            body.withLogCollection(CreateClusterReqV2.LogCollectionEnum.NUMBER_1);
            body.withTags(listbodyTags);
            body.withMrsEcsDefaultAgency("MRS_ECS_DEFAULT_AGENCY");
            body.withNodeRootPassword("your password");
            body.withLoginMode("PASSWORD");
            body.withManagerAdminPassword("your password");
            body.withSafeMode("KERBEROS");
            body.withAvailabilityZone("");
            body.withComponents("Hadoop,Spark2x,HBase,Hive,Hue,Loader,Flink,Oozie,Ranger,Tez");
            body.withSubnetName("subnet");
            body.withSubnetId("1f8c5ca6-1f66-4096-bb00-baf175954f6e");
            body.withVpcName("vpc-37cd");
            body.withRegion("");
            body.withChargeInfo(chargeInfobody);
            body.withClusterType("ANALYSIS");
            body.withClusterName("mrs_DyJA_dm");
            body.withClusterVersion("MRS 3.1.0");
            request.withBody(body);
            try {
                CreateClusterResponse response = client.createCluster(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());
            }
        }
    }
    
  • Create a streaming cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with zero nodes. Autoscaling is enabled every Monday from 12:00 to 13:00.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    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 CreateClusterSolution {
    
        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();
            CreateClusterRequest request = new CreateClusterRequest();
            CreateClusterReqV2 body = new CreateClusterReqV2();
            Trigger triggerRules = new Trigger();
            triggerRules.withMetricName("StormSlotAvailablePercentage")
                .withMetricValue("100")
                .withComparisonOperator("LTOE")
                .withEvaluationPeriods(1);
            List<Rule> listAutoScalingPolicyRules = new ArrayList<>();
            listAutoScalingPolicyRules.add(
                new Rule()
                    .withName("default-expand-1")
                    .withDescription("")
                    .withAdjustmentType(Rule.AdjustmentTypeEnum.fromValue("scale_out"))
                    .withCoolDownMinutes(5)
                    .withScalingAdjustment(1)
                    .withTrigger(triggerRules)
            );
            List<ResourcesPlan.EffectiveDaysEnum> listResourcesPlansEffectiveDays = new ArrayList<>();
            listResourcesPlansEffectiveDays.add(ResourcesPlan.EffectiveDaysEnum.fromValue("MONDAY"));
            List<ResourcesPlan> listAutoScalingPolicyResourcesPlans = new ArrayList<>();
            listAutoScalingPolicyResourcesPlans.add(
                new ResourcesPlan()
                    .withPeriodType("daily")
                    .withStartTime("12:00")
                    .withEndTime("13:00")
                    .withMinCapacity(2)
                    .withMaxCapacity(3)
                    .withEffectiveDays(listResourcesPlansEffectiveDays)
            );
            AutoScalingPolicy autoScalingPolicyNodeGroups = new AutoScalingPolicy();
            autoScalingPolicyNodeGroups.withAutoScalingEnable(true)
                .withMinCapacity(0)
                .withMaxCapacity(1)
                .withResourcesPlans(listAutoScalingPolicyResourcesPlans)
                .withRules(listAutoScalingPolicyRules);
            Volume dataVolumeNodeGroups = new Volume();
            dataVolumeNodeGroups.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups = new Volume();
            rootVolumeNodeGroups.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups1 = new Volume();
            dataVolumeNodeGroups1.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups1 = new Volume();
            rootVolumeNodeGroups1.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups2 = new Volume();
            dataVolumeNodeGroups2.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups2 = new Volume();
            rootVolumeNodeGroups2.withType("SAS")
                .withSize(480);
            List<NodeGroupV2> listbodyNodeGroups = new ArrayList<>();
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("master_node_default_group")
                    .withNodeNum(2)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups2)
                    .withDataVolume(dataVolumeNodeGroups2)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("core_node_streaming_group")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups1)
                    .withDataVolume(dataVolumeNodeGroups1)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("task_node_streaming_group")
                    .withNodeNum(0)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups)
                    .withDataVolume(dataVolumeNodeGroups)
                    .withDataVolumeCount(1)
                    .withAutoScalingPolicy(autoScalingPolicyNodeGroups)
            );
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("tag1")
                    .withValue("111")
            );
            listbodyTags.add(
                new Tag()
                    .withKey("tag2")
                    .withValue("222")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            body.withNodeGroups(listbodyNodeGroups);
            body.withLogCollection(CreateClusterReqV2.LogCollectionEnum.NUMBER_1);
            body.withTags(listbodyTags);
            body.withMrsEcsDefaultAgency("MRS_ECS_DEFAULT_AGENCY");
            body.withNodeRootPassword("your password");
            body.withLoginMode("PASSWORD");
            body.withManagerAdminPassword("your password");
            body.withSafeMode("KERBEROS");
            body.withAvailabilityZone("");
            body.withComponents("Storm,Kafka,Flume,Ranger");
            body.withSubnetName("subnet");
            body.withSubnetId("1f8c5ca6-1f66-4096-bb00-baf175954f6e");
            body.withVpcName("vpc-37cd");
            body.withRegion("");
            body.withChargeInfo(chargeInfobody);
            body.withClusterType("STREAMING");
            body.withClusterName("mrs_Dokle_dm");
            body.withClusterVersion("MRS 3.1.0");
            request.withBody(body);
            try {
                CreateClusterResponse response = client.createCluster(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());
            }
        }
    }
    
  • Create a hybrid cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, two Core node groups with three nodes each, and two Task node groups — one with one node and the other with zero nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    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 CreateClusterSolution {
    
        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();
            CreateClusterRequest request = new CreateClusterRequest();
            CreateClusterReqV2 body = new CreateClusterReqV2();
            Volume dataVolumeNodeGroups = new Volume();
            dataVolumeNodeGroups.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups = new Volume();
            rootVolumeNodeGroups.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups1 = new Volume();
            dataVolumeNodeGroups1.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups1 = new Volume();
            rootVolumeNodeGroups1.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups2 = new Volume();
            dataVolumeNodeGroups2.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups2 = new Volume();
            rootVolumeNodeGroups2.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups3 = new Volume();
            dataVolumeNodeGroups3.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups3 = new Volume();
            rootVolumeNodeGroups3.withType("SAS")
                .withSize(480);
            Volume dataVolumeNodeGroups4 = new Volume();
            dataVolumeNodeGroups4.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups4 = new Volume();
            rootVolumeNodeGroups4.withType("SAS")
                .withSize(480);
            List<NodeGroupV2> listbodyNodeGroups = new ArrayList<>();
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("master_node_default_group")
                    .withNodeNum(2)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups4)
                    .withDataVolume(dataVolumeNodeGroups4)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("core_node_streaming_group")
                    .withNodeNum(3)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups3)
                    .withDataVolume(dataVolumeNodeGroups3)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("core_node_analysis_group")
                    .withNodeNum(3)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups2)
                    .withDataVolume(dataVolumeNodeGroups2)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("task_node_analysis_group")
                    .withNodeNum(1)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups1)
                    .withDataVolume(dataVolumeNodeGroups1)
                    .withDataVolumeCount(1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("task_node_streaming_group")
                    .withNodeNum(0)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups)
                    .withDataVolume(dataVolumeNodeGroups)
                    .withDataVolumeCount(1)
            );
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("tag1")
                    .withValue("111")
            );
            listbodyTags.add(
                new Tag()
                    .withKey("tag2")
                    .withValue("222")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            body.withNodeGroups(listbodyNodeGroups);
            body.withLogCollection(CreateClusterReqV2.LogCollectionEnum.NUMBER_1);
            body.withTags(listbodyTags);
            body.withMrsEcsDefaultAgency("MRS_ECS_DEFAULT_AGENCY");
            body.withNodeRootPassword("your password");
            body.withLoginMode("PASSWORD");
            body.withManagerAdminPassword("your password");
            body.withSafeMode("KERBEROS");
            body.withAvailabilityZone("");
            body.withComponents("Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez");
            body.withSubnetName("subnet");
            body.withSubnetId("1f8c5ca6-1f66-4096-bb00-baf175954f6e");
            body.withVpcName("vpc-37cd");
            body.withRegion("");
            body.withChargeInfo(chargeInfobody);
            body.withClusterType("MIXED");
            body.withClusterName("mrs_onmm_dm");
            body.withClusterVersion("MRS 3.1.0");
            request.withBody(body);
            try {
                CreateClusterResponse response = client.createCluster(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());
            }
        }
    }
    
  • Create a custom cluster where management and control nodes are co-located, with cluster version MRS 3.1.0. The cluster contains one Master node group with three nodes, and two Core node groups — one with three nodes and the other with one node.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    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 CreateClusterSolution {
    
        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();
            CreateClusterRequest request = new CreateClusterRequest();
            CreateClusterReqV2 body = new CreateClusterReqV2();
            List<String> listNodeGroupsAssignedRoles = new ArrayList<>();
            listNodeGroupsAssignedRoles.add("NodeManager");
            listNodeGroupsAssignedRoles.add("KerberosClient");
            listNodeGroupsAssignedRoles.add("SlapdClient");
            listNodeGroupsAssignedRoles.add("meta");
            listNodeGroupsAssignedRoles.add("FlinkResource");
            Volume dataVolumeNodeGroups = new Volume();
            dataVolumeNodeGroups.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups = new Volume();
            rootVolumeNodeGroups.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles1 = new ArrayList<>();
            listNodeGroupsAssignedRoles1.add("DataNode");
            listNodeGroupsAssignedRoles1.add("NodeManager");
            listNodeGroupsAssignedRoles1.add("RegionServer");
            listNodeGroupsAssignedRoles1.add("Flume:1");
            listNodeGroupsAssignedRoles1.add("Broker");
            listNodeGroupsAssignedRoles1.add("Supervisor");
            listNodeGroupsAssignedRoles1.add("Logviewer");
            listNodeGroupsAssignedRoles1.add("HBaseIndexer");
            listNodeGroupsAssignedRoles1.add("KerberosClient");
            listNodeGroupsAssignedRoles1.add("SlapdClient");
            listNodeGroupsAssignedRoles1.add("meta");
            listNodeGroupsAssignedRoles1.add("HSBroker:1,2");
            listNodeGroupsAssignedRoles1.add("ThriftServer");
            listNodeGroupsAssignedRoles1.add("ThriftServer1");
            listNodeGroupsAssignedRoles1.add("RESTServer");
            listNodeGroupsAssignedRoles1.add("FlinkResource");
            Volume dataVolumeNodeGroups1 = new Volume();
            dataVolumeNodeGroups1.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups1 = new Volume();
            rootVolumeNodeGroups1.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles2 = new ArrayList<>();
            listNodeGroupsAssignedRoles2.add("OMSServer:1,2");
            listNodeGroupsAssignedRoles2.add("SlapdServer:1,2");
            listNodeGroupsAssignedRoles2.add("KerberosServer:1,2");
            listNodeGroupsAssignedRoles2.add("KerberosAdmin:1,2");
            listNodeGroupsAssignedRoles2.add("quorumpeer:1,2,3");
            listNodeGroupsAssignedRoles2.add("NameNode:2,3");
            listNodeGroupsAssignedRoles2.add("Zkfc:2,3");
            listNodeGroupsAssignedRoles2.add("JournalNode:1,2,3");
            listNodeGroupsAssignedRoles2.add("ResourceManager:2,3");
            listNodeGroupsAssignedRoles2.add("JobHistoryServer:2,3");
            listNodeGroupsAssignedRoles2.add("DBServer:1,3");
            listNodeGroupsAssignedRoles2.add("Hue:1,3");
            listNodeGroupsAssignedRoles2.add("LoaderServer:1,3");
            listNodeGroupsAssignedRoles2.add("MetaStore:1,2,3");
            listNodeGroupsAssignedRoles2.add("WebHCat:1,2,3");
            listNodeGroupsAssignedRoles2.add("HiveServer:1,2,3");
            listNodeGroupsAssignedRoles2.add("HMaster:2,3");
            listNodeGroupsAssignedRoles2.add("MonitorServer:1,2");
            listNodeGroupsAssignedRoles2.add("Nimbus:1,2");
            listNodeGroupsAssignedRoles2.add("UI:1,2");
            listNodeGroupsAssignedRoles2.add("JDBCServer2x:1,2,3");
            listNodeGroupsAssignedRoles2.add("JobHistory2x:2,3");
            listNodeGroupsAssignedRoles2.add("SparkResource2x:1,2,3");
            listNodeGroupsAssignedRoles2.add("oozie:2,3");
            listNodeGroupsAssignedRoles2.add("LoadBalancer:2,3");
            listNodeGroupsAssignedRoles2.add("TezUI:1,3");
            listNodeGroupsAssignedRoles2.add("TimelineServer:3");
            listNodeGroupsAssignedRoles2.add("RangerAdmin:1,2");
            listNodeGroupsAssignedRoles2.add("UserSync:2");
            listNodeGroupsAssignedRoles2.add("TagSync:2");
            listNodeGroupsAssignedRoles2.add("KerberosClient");
            listNodeGroupsAssignedRoles2.add("SlapdClient");
            listNodeGroupsAssignedRoles2.add("meta");
            listNodeGroupsAssignedRoles2.add("HSConsole:2,3");
            listNodeGroupsAssignedRoles2.add("FlinkResource:1,2,3");
            listNodeGroupsAssignedRoles2.add("DataNode:1,2,3");
            listNodeGroupsAssignedRoles2.add("NodeManager:1,2,3");
            listNodeGroupsAssignedRoles2.add("IndexServer2x:1,2");
            listNodeGroupsAssignedRoles2.add("ThriftServer:1,2,3");
            listNodeGroupsAssignedRoles2.add("RegionServer:1,2,3");
            listNodeGroupsAssignedRoles2.add("ThriftServer1:1,2,3");
            listNodeGroupsAssignedRoles2.add("RESTServer:1,2,3");
            listNodeGroupsAssignedRoles2.add("Broker:1,2,3");
            listNodeGroupsAssignedRoles2.add("Supervisor:1,2,3");
            listNodeGroupsAssignedRoles2.add("Logviewer:1,2,3");
            listNodeGroupsAssignedRoles2.add("Flume:1,2,3");
            listNodeGroupsAssignedRoles2.add("HSBroker:1,2,3");
            Volume dataVolumeNodeGroups2 = new Volume();
            dataVolumeNodeGroups2.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups2 = new Volume();
            rootVolumeNodeGroups2.withType("SAS")
                .withSize(480);
            List<NodeGroupV2> listbodyNodeGroups = new ArrayList<>();
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("master_node_default_group")
                    .withNodeNum(3)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups2)
                    .withDataVolume(dataVolumeNodeGroups2)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles2)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_1")
                    .withNodeNum(3)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups1)
                    .withDataVolume(dataVolumeNodeGroups1)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_2")
                    .withNodeNum(1)
                    .withNodeSize("Sit3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups)
                    .withDataVolume(dataVolumeNodeGroups)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles)
            );
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("tag1")
                    .withValue("111")
            );
            listbodyTags.add(
                new Tag()
                    .withKey("tag2")
                    .withValue("222")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            body.withNodeGroups(listbodyNodeGroups);
            body.withLogCollection(CreateClusterReqV2.LogCollectionEnum.NUMBER_1);
            body.withTags(listbodyTags);
            body.withTemplateId("mgmt_control_combined_v2");
            body.withMrsEcsDefaultAgency("MRS_ECS_DEFAULT_AGENCY");
            body.withNodeRootPassword("your password");
            body.withLoginMode("PASSWORD");
            body.withManagerAdminPassword("your password");
            body.withSafeMode("KERBEROS");
            body.withAvailabilityZone("");
            body.withComponents("Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez");
            body.withSubnetName("subnet");
            body.withSubnetId("1f8c5ca6-1f66-4096-bb00-baf175954f6e");
            body.withVpcName("vpc-37cd");
            body.withRegion("");
            body.withChargeInfo(chargeInfobody);
            body.withClusterType("CUSTOM");
            body.withClusterName("mrs_heshe_dm");
            body.withClusterVersion("MRS 3.1.0");
            request.withBody(body);
            try {
                CreateClusterResponse response = client.createCluster(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());
            }
        }
    }
    
  • Create a custom cluster where management and control nodes are separated, with cluster version MRS 3.1.0. The cluster contains one Master node group with five nodes and one Core node group with three nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    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 CreateClusterSolution {
    
        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();
            CreateClusterRequest request = new CreateClusterRequest();
            CreateClusterReqV2 body = new CreateClusterReqV2();
            List<String> listNodeGroupsAssignedRoles = new ArrayList<>();
            listNodeGroupsAssignedRoles.add("DataNode");
            listNodeGroupsAssignedRoles.add("NodeManager");
            listNodeGroupsAssignedRoles.add("RegionServer");
            listNodeGroupsAssignedRoles.add("Flume:1");
            listNodeGroupsAssignedRoles.add("Broker");
            listNodeGroupsAssignedRoles.add("Supervisor");
            listNodeGroupsAssignedRoles.add("Logviewer");
            listNodeGroupsAssignedRoles.add("HBaseIndexer");
            listNodeGroupsAssignedRoles.add("KerberosClient");
            listNodeGroupsAssignedRoles.add("SlapdClient");
            listNodeGroupsAssignedRoles.add("meta");
            listNodeGroupsAssignedRoles.add("HSBroker:1,2");
            listNodeGroupsAssignedRoles.add("ThriftServer");
            listNodeGroupsAssignedRoles.add("ThriftServer1");
            listNodeGroupsAssignedRoles.add("RESTServer");
            listNodeGroupsAssignedRoles.add("FlinkResource");
            Volume dataVolumeNodeGroups = new Volume();
            dataVolumeNodeGroups.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups = new Volume();
            rootVolumeNodeGroups.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles1 = new ArrayList<>();
            listNodeGroupsAssignedRoles1.add("OMSServer:1,2");
            listNodeGroupsAssignedRoles1.add("SlapdServer:3,4");
            listNodeGroupsAssignedRoles1.add("KerberosServer:3,4");
            listNodeGroupsAssignedRoles1.add("KerberosAdmin:3,4");
            listNodeGroupsAssignedRoles1.add("quorumpeer:3,4,5");
            listNodeGroupsAssignedRoles1.add("NameNode:4,5");
            listNodeGroupsAssignedRoles1.add("Zkfc:4,5");
            listNodeGroupsAssignedRoles1.add("JournalNode:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("ResourceManager:4,5");
            listNodeGroupsAssignedRoles1.add("JobHistoryServer:4,5");
            listNodeGroupsAssignedRoles1.add("DBServer:3,5");
            listNodeGroupsAssignedRoles1.add("Hue:1,2");
            listNodeGroupsAssignedRoles1.add("LoaderServer:1,2");
            listNodeGroupsAssignedRoles1.add("MetaStore:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("WebHCat:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("HiveServer:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("HMaster:4,5");
            listNodeGroupsAssignedRoles1.add("MonitorServer:1,2");
            listNodeGroupsAssignedRoles1.add("Nimbus:1,2");
            listNodeGroupsAssignedRoles1.add("UI:1,2");
            listNodeGroupsAssignedRoles1.add("JDBCServer2x:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("JobHistory2x:4,5");
            listNodeGroupsAssignedRoles1.add("SparkResource2x:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("oozie:1,2");
            listNodeGroupsAssignedRoles1.add("LoadBalancer:1,2");
            listNodeGroupsAssignedRoles1.add("TezUI:1,2");
            listNodeGroupsAssignedRoles1.add("TimelineServer:5");
            listNodeGroupsAssignedRoles1.add("RangerAdmin:1,2");
            listNodeGroupsAssignedRoles1.add("KerberosClient");
            listNodeGroupsAssignedRoles1.add("SlapdClient");
            listNodeGroupsAssignedRoles1.add("meta");
            listNodeGroupsAssignedRoles1.add("HSConsole:1,2");
            listNodeGroupsAssignedRoles1.add("FlinkResource:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("DataNode:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("NodeManager:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("IndexServer2x:1,2");
            listNodeGroupsAssignedRoles1.add("ThriftServer:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("RegionServer:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("ThriftServer1:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("RESTServer:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("Broker:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("Supervisor:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("Logviewer:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("Flume:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("HBaseIndexer:1,2,3,4,5");
            listNodeGroupsAssignedRoles1.add("TagSync:1");
            listNodeGroupsAssignedRoles1.add("UserSync:1");
            Volume dataVolumeNodeGroups1 = new Volume();
            dataVolumeNodeGroups1.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups1 = new Volume();
            rootVolumeNodeGroups1.withType("SAS")
                .withSize(480);
            List<NodeGroupV2> listbodyNodeGroups = new ArrayList<>();
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("master_node_default_group")
                    .withNodeNum(5)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups1)
                    .withDataVolume(dataVolumeNodeGroups1)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_1")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups)
                    .withDataVolume(dataVolumeNodeGroups)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles)
            );
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("aaa")
                    .withValue("111")
            );
            listbodyTags.add(
                new Tag()
                    .withKey("bbb")
                    .withValue("222")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            body.withNodeGroups(listbodyNodeGroups);
            body.withLogCollection(CreateClusterReqV2.LogCollectionEnum.NUMBER_1);
            body.withTags(listbodyTags);
            body.withTemplateId("mgmt_control_separated_v2");
            body.withMrsEcsDefaultAgency("MRS_ECS_DEFAULT_AGENCY");
            body.withNodeRootPassword("your password");
            body.withLoginMode("PASSWORD");
            body.withManagerAdminPassword("your password");
            body.withSafeMode("KERBEROS");
            body.withAvailabilityZone("");
            body.withComponents("Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez");
            body.withSubnetName("subnet");
            body.withSubnetId("1f8c5ca6-1f66-4096-bb00-baf175954f6e");
            body.withVpcName("vpc-37cd");
            body.withRegion("");
            body.withChargeInfo(chargeInfobody);
            body.withClusterType("CUSTOM");
            body.withClusterName("mrs_jdRU_dm01");
            body.withClusterVersion("MRS 3.1.0");
            request.withBody(body);
            try {
                CreateClusterResponse response = client.createCluster(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());
            }
        }
    }
    
  • Create a custom cluster where data nodes are deployed separately, with cluster version MRS 3.1.0. The cluster contains one Master node group with nine nodes and four Core node groups, each with three nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    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 CreateClusterSolution {
    
        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();
            CreateClusterRequest request = new CreateClusterRequest();
            CreateClusterReqV2 body = new CreateClusterReqV2();
            List<String> listNodeGroupsAssignedRoles = new ArrayList<>();
            listNodeGroupsAssignedRoles.add("Broker");
            listNodeGroupsAssignedRoles.add("Supervisor");
            listNodeGroupsAssignedRoles.add("Logviewer");
            listNodeGroupsAssignedRoles.add("KerberosClient");
            listNodeGroupsAssignedRoles.add("SlapdClient");
            listNodeGroupsAssignedRoles.add("meta");
            Volume dataVolumeNodeGroups = new Volume();
            dataVolumeNodeGroups.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups = new Volume();
            rootVolumeNodeGroups.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles1 = new ArrayList<>();
            listNodeGroupsAssignedRoles1.add("KerberosClient");
            listNodeGroupsAssignedRoles1.add("SlapdClient");
            listNodeGroupsAssignedRoles1.add("meta");
            Volume dataVolumeNodeGroups1 = new Volume();
            dataVolumeNodeGroups1.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups1 = new Volume();
            rootVolumeNodeGroups1.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles2 = new ArrayList<>();
            listNodeGroupsAssignedRoles2.add("HBaseIndexer");
            listNodeGroupsAssignedRoles2.add("SolrServer[3]");
            listNodeGroupsAssignedRoles2.add("EsNode[2]");
            listNodeGroupsAssignedRoles2.add("KerberosClient");
            listNodeGroupsAssignedRoles2.add("SlapdClient");
            listNodeGroupsAssignedRoles2.add("meta");
            listNodeGroupsAssignedRoles2.add("SolrServerAdmin:1,2");
            Volume dataVolumeNodeGroups2 = new Volume();
            dataVolumeNodeGroups2.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups2 = new Volume();
            rootVolumeNodeGroups2.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles3 = new ArrayList<>();
            listNodeGroupsAssignedRoles3.add("DataNode");
            listNodeGroupsAssignedRoles3.add("NodeManager");
            listNodeGroupsAssignedRoles3.add("RegionServer");
            listNodeGroupsAssignedRoles3.add("Flume:1");
            listNodeGroupsAssignedRoles3.add("GraphServer");
            listNodeGroupsAssignedRoles3.add("KerberosClient");
            listNodeGroupsAssignedRoles3.add("SlapdClient");
            listNodeGroupsAssignedRoles3.add("meta");
            listNodeGroupsAssignedRoles3.add("HSBroker:1,2");
            Volume dataVolumeNodeGroups3 = new Volume();
            dataVolumeNodeGroups3.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups3 = new Volume();
            rootVolumeNodeGroups3.withType("SAS")
                .withSize(480);
            List<String> listNodeGroupsAssignedRoles4 = new ArrayList<>();
            listNodeGroupsAssignedRoles4.add("OMSServer:1,2");
            listNodeGroupsAssignedRoles4.add("SlapdServer:5,6");
            listNodeGroupsAssignedRoles4.add("KerberosServer:5,6");
            listNodeGroupsAssignedRoles4.add("KerberosAdmin:5,6");
            listNodeGroupsAssignedRoles4.add("quorumpeer:5,6,7,8,9");
            listNodeGroupsAssignedRoles4.add("NameNode:3,4");
            listNodeGroupsAssignedRoles4.add("Zkfc:3,4");
            listNodeGroupsAssignedRoles4.add("JournalNode:5,6,7");
            listNodeGroupsAssignedRoles4.add("ResourceManager:8,9");
            listNodeGroupsAssignedRoles4.add("JobHistoryServer:8");
            listNodeGroupsAssignedRoles4.add("DBServer:8,9");
            listNodeGroupsAssignedRoles4.add("Hue:8,9");
            listNodeGroupsAssignedRoles4.add("FlinkResource:3,4");
            listNodeGroupsAssignedRoles4.add("LoaderServer:3,5");
            listNodeGroupsAssignedRoles4.add("MetaStore:8,9");
            listNodeGroupsAssignedRoles4.add("WebHCat:5");
            listNodeGroupsAssignedRoles4.add("HiveServer:8,9");
            listNodeGroupsAssignedRoles4.add("HMaster:8,9");
            listNodeGroupsAssignedRoles4.add("FTP-Server:3,4");
            listNodeGroupsAssignedRoles4.add("MonitorServer:3,4");
            listNodeGroupsAssignedRoles4.add("Nimbus:8,9");
            listNodeGroupsAssignedRoles4.add("UI:8,9");
            listNodeGroupsAssignedRoles4.add("JDBCServer2x:8,9");
            listNodeGroupsAssignedRoles4.add("JobHistory2x:8,9");
            listNodeGroupsAssignedRoles4.add("SparkResource2x:5,6,7");
            listNodeGroupsAssignedRoles4.add("oozie:4,5");
            listNodeGroupsAssignedRoles4.add("EsMaster:7,8,9");
            listNodeGroupsAssignedRoles4.add("LoadBalancer:8,9");
            listNodeGroupsAssignedRoles4.add("TezUI:5,6");
            listNodeGroupsAssignedRoles4.add("TimelineServer:5");
            listNodeGroupsAssignedRoles4.add("RangerAdmin:4,5");
            listNodeGroupsAssignedRoles4.add("UserSync:5");
            listNodeGroupsAssignedRoles4.add("TagSync:5");
            listNodeGroupsAssignedRoles4.add("KerberosClient");
            listNodeGroupsAssignedRoles4.add("SlapdClient");
            listNodeGroupsAssignedRoles4.add("meta");
            listNodeGroupsAssignedRoles4.add("HSBroker:5");
            listNodeGroupsAssignedRoles4.add("HSConsole:3,4");
            listNodeGroupsAssignedRoles4.add("FlinkResource:3,4");
            Volume dataVolumeNodeGroups4 = new Volume();
            dataVolumeNodeGroups4.withType("SAS")
                .withSize(600);
            Volume rootVolumeNodeGroups4 = new Volume();
            rootVolumeNodeGroups4.withType("SAS")
                .withSize(480);
            List<NodeGroupV2> listbodyNodeGroups = new ArrayList<>();
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("master_node_default_group")
                    .withNodeNum(9)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups4)
                    .withDataVolume(dataVolumeNodeGroups4)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles4)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_1")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups3)
                    .withDataVolume(dataVolumeNodeGroups3)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles3)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_2")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups2)
                    .withDataVolume(dataVolumeNodeGroups2)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles2)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_3")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups1)
                    .withDataVolume(dataVolumeNodeGroups1)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles1)
            );
            listbodyNodeGroups.add(
                new NodeGroupV2()
                    .withGroupName("node_group_4")
                    .withNodeNum(3)
                    .withNodeSize("rc3.4xlarge.4.linux.bigdata")
                    .withRootVolume(rootVolumeNodeGroups)
                    .withDataVolume(dataVolumeNodeGroups)
                    .withDataVolumeCount(1)
                    .withAssignedRoles(listNodeGroupsAssignedRoles)
            );
            List<Tag> listbodyTags = new ArrayList<>();
            listbodyTags.add(
                new Tag()
                    .withKey("aaa")
                    .withValue("111")
            );
            listbodyTags.add(
                new Tag()
                    .withKey("bbb")
                    .withValue("222")
            );
            ChargeInfo chargeInfobody = new ChargeInfo();
            chargeInfobody.withChargeMode("postPaid");
            body.withNodeGroups(listbodyNodeGroups);
            body.withLogCollection(CreateClusterReqV2.LogCollectionEnum.NUMBER_1);
            body.withTags(listbodyTags);
            body.withTemplateId("mgmt_control_data_separated_v2");
            body.withMrsEcsDefaultAgency("MRS_ECS_DEFAULT_AGENCY");
            body.withNodeRootPassword("your password");
            body.withLoginMode("PASSWORD");
            body.withManagerAdminPassword("your password");
            body.withSafeMode("KERBEROS");
            body.withAvailabilityZone("");
            body.withComponents("Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez");
            body.withSubnetName("subnet");
            body.withSubnetId("1f8c5ca6-1f66-4096-bb00-baf175954f6e");
            body.withVpcName("vpc-37cd");
            body.withRegion("");
            body.withChargeInfo(chargeInfobody);
            body.withClusterType("CUSTOM");
            body.withClusterName("mrs_jdRU_dm02");
            body.withClusterVersion("MRS 3.1.0");
            request.withBody(body);
            try {
                CreateClusterResponse response = client.createCluster(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());
            }
        }
    }
    
  • Create an analysis cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with three nodes. Autoscaling is enabled every Monday from 12:00 to 13:00. The initial configuration hive.union.data.type.incompatible.enable of the Hive component is changed to true, and dfs.replication is changed to 4.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    # 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 = CreateClusterRequest()
            listConfigsComponentConfigs = [
                Config(
                    key="hive.union.data.type.incompatible.enable",
                    value="true",
                    config_file_name="hive-site.xml"
                ),
                Config(
                    key="dfs.replication",
                    value="4",
                    config_file_name="hdfs-site.xml"
                )
            ]
            listComponentConfigsbody = [
                ComponentConfig(
                    component_name="Hive",
                    configs=listConfigsComponentConfigs
                )
            ]
            listNodesExecScripts = [
                "master_node_default_group",
                "core_node_analysis_group",
                "task_node_analysis_group"
            ]
            listExecScriptsAutoScalingPolicy = [
                ScaleScript(
                    name="test",
                    uri="s3a://obs-mrstest/bootstrap/basic_success.sh",
                    parameters="",
                    nodes=listNodesExecScripts,
                    active_master=False,
                    fail_action="continue",
                    action_stage="before_scale_out"
                )
            ]
            triggerRules = Trigger(
                metric_name="YARNAppRunning",
                metric_value="100",
                comparison_operator="GTOE",
                evaluation_periods=1
            )
            listRulesAutoScalingPolicy = [
                Rule(
                    name="default-expand-1",
                    description="",
                    adjustment_type="scale_out",
                    cool_down_minutes=5,
                    scaling_adjustment=1,
                    trigger=triggerRules
                )
            ]
            listEffectiveDaysResourcesPlans = [
                "MONDAY"
            ]
            listResourcesPlansAutoScalingPolicy = [
                ResourcesPlan(
                    period_type="daily",
                    start_time="12:00",
                    end_time="13:00",
                    min_capacity=2,
                    max_capacity=3,
                    effective_days=listEffectiveDaysResourcesPlans
                )
            ]
            autoScalingPolicyNodeGroups = AutoScalingPolicy(
                auto_scaling_enable=True,
                min_capacity=0,
                max_capacity=1,
                resources_plans=listResourcesPlansAutoScalingPolicy,
                rules=listRulesAutoScalingPolicy,
                exec_scripts=listExecScriptsAutoScalingPolicy
            )
            dataVolumeNodeGroups = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups1 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups1 = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups2 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups2 = Volume(
                type="SAS",
                size=480
            )
            listNodeGroupsbody = [
                NodeGroupV2(
                    group_name="master_node_default_group",
                    node_num=2,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups2,
                    data_volume=dataVolumeNodeGroups2,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="core_node_analysis_group",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups1,
                    data_volume=dataVolumeNodeGroups1,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="task_node_analysis_group",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups,
                    data_volume=dataVolumeNodeGroups,
                    data_volume_count=1,
                    auto_scaling_policy=autoScalingPolicyNodeGroups
                )
            ]
            listTagsbody = [
                Tag(
                    key="tag1",
                    value="111"
                ),
                Tag(
                    key="tag2",
                    value="222"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            request.body = CreateClusterReqV2(
                component_configs=listComponentConfigsbody,
                node_groups=listNodeGroupsbody,
                log_collection=1,
                tags=listTagsbody,
                mrs_ecs_default_agency="MRS_ECS_DEFAULT_AGENCY",
                node_root_password="your password",
                login_mode="PASSWORD",
                manager_admin_password="your password",
                safe_mode="KERBEROS",
                availability_zone="",
                components="Hadoop,Spark2x,HBase,Hive,Hue,Loader,Flink,Oozie,Ranger,Tez",
                subnet_name="subnet",
                subnet_id="1f8c5ca6-1f66-4096-bb00-baf175954f6e",
                vpc_name="vpc-37cd",
                region="",
                charge_info=chargeInfobody,
                cluster_type="ANALYSIS",
                cluster_name="mrs_DyJA_dm",
                cluster_version="MRS 3.1.0"
            )
            response = client.create_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a streaming cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with zero nodes. Autoscaling is enabled every Monday from 12:00 to 13:00.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    # 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 = CreateClusterRequest()
            triggerRules = Trigger(
                metric_name="StormSlotAvailablePercentage",
                metric_value="100",
                comparison_operator="LTOE",
                evaluation_periods=1
            )
            listRulesAutoScalingPolicy = [
                Rule(
                    name="default-expand-1",
                    description="",
                    adjustment_type="scale_out",
                    cool_down_minutes=5,
                    scaling_adjustment=1,
                    trigger=triggerRules
                )
            ]
            listEffectiveDaysResourcesPlans = [
                "MONDAY"
            ]
            listResourcesPlansAutoScalingPolicy = [
                ResourcesPlan(
                    period_type="daily",
                    start_time="12:00",
                    end_time="13:00",
                    min_capacity=2,
                    max_capacity=3,
                    effective_days=listEffectiveDaysResourcesPlans
                )
            ]
            autoScalingPolicyNodeGroups = AutoScalingPolicy(
                auto_scaling_enable=True,
                min_capacity=0,
                max_capacity=1,
                resources_plans=listResourcesPlansAutoScalingPolicy,
                rules=listRulesAutoScalingPolicy
            )
            dataVolumeNodeGroups = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups1 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups1 = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups2 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups2 = Volume(
                type="SAS",
                size=480
            )
            listNodeGroupsbody = [
                NodeGroupV2(
                    group_name="master_node_default_group",
                    node_num=2,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups2,
                    data_volume=dataVolumeNodeGroups2,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="core_node_streaming_group",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups1,
                    data_volume=dataVolumeNodeGroups1,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="task_node_streaming_group",
                    node_num=0,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups,
                    data_volume=dataVolumeNodeGroups,
                    data_volume_count=1,
                    auto_scaling_policy=autoScalingPolicyNodeGroups
                )
            ]
            listTagsbody = [
                Tag(
                    key="tag1",
                    value="111"
                ),
                Tag(
                    key="tag2",
                    value="222"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            request.body = CreateClusterReqV2(
                node_groups=listNodeGroupsbody,
                log_collection=1,
                tags=listTagsbody,
                mrs_ecs_default_agency="MRS_ECS_DEFAULT_AGENCY",
                node_root_password="your password",
                login_mode="PASSWORD",
                manager_admin_password="your password",
                safe_mode="KERBEROS",
                availability_zone="",
                components="Storm,Kafka,Flume,Ranger",
                subnet_name="subnet",
                subnet_id="1f8c5ca6-1f66-4096-bb00-baf175954f6e",
                vpc_name="vpc-37cd",
                region="",
                charge_info=chargeInfobody,
                cluster_type="STREAMING",
                cluster_name="mrs_Dokle_dm",
                cluster_version="MRS 3.1.0"
            )
            response = client.create_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a hybrid cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, two Core node groups with three nodes each, and two Task node groups — one with one node and the other with zero nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    # 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 = CreateClusterRequest()
            dataVolumeNodeGroups = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups1 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups1 = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups2 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups2 = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups3 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups3 = Volume(
                type="SAS",
                size=480
            )
            dataVolumeNodeGroups4 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups4 = Volume(
                type="SAS",
                size=480
            )
            listNodeGroupsbody = [
                NodeGroupV2(
                    group_name="master_node_default_group",
                    node_num=2,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups4,
                    data_volume=dataVolumeNodeGroups4,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="core_node_streaming_group",
                    node_num=3,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups3,
                    data_volume=dataVolumeNodeGroups3,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="core_node_analysis_group",
                    node_num=3,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups2,
                    data_volume=dataVolumeNodeGroups2,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="task_node_analysis_group",
                    node_num=1,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups1,
                    data_volume=dataVolumeNodeGroups1,
                    data_volume_count=1
                ),
                NodeGroupV2(
                    group_name="task_node_streaming_group",
                    node_num=0,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups,
                    data_volume=dataVolumeNodeGroups,
                    data_volume_count=1
                )
            ]
            listTagsbody = [
                Tag(
                    key="tag1",
                    value="111"
                ),
                Tag(
                    key="tag2",
                    value="222"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            request.body = CreateClusterReqV2(
                node_groups=listNodeGroupsbody,
                log_collection=1,
                tags=listTagsbody,
                mrs_ecs_default_agency="MRS_ECS_DEFAULT_AGENCY",
                node_root_password="your password",
                login_mode="PASSWORD",
                manager_admin_password="your password",
                safe_mode="KERBEROS",
                availability_zone="",
                components="Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
                subnet_name="subnet",
                subnet_id="1f8c5ca6-1f66-4096-bb00-baf175954f6e",
                vpc_name="vpc-37cd",
                region="",
                charge_info=chargeInfobody,
                cluster_type="MIXED",
                cluster_name="mrs_onmm_dm",
                cluster_version="MRS 3.1.0"
            )
            response = client.create_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a custom cluster where management and control nodes are co-located, with cluster version MRS 3.1.0. The cluster contains one Master node group with three nodes, and two Core node groups — one with three nodes and the other with one node.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    # 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 = CreateClusterRequest()
            listAssignedRolesNodeGroups = [
                "NodeManager",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "FlinkResource"
            ]
            dataVolumeNodeGroups = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups1 = [
                "DataNode",
                "NodeManager",
                "RegionServer",
                "Flume:1",
                "Broker",
                "Supervisor",
                "Logviewer",
                "HBaseIndexer",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "HSBroker:1,2",
                "ThriftServer",
                "ThriftServer1",
                "RESTServer",
                "FlinkResource"
            ]
            dataVolumeNodeGroups1 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups1 = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups2 = [
                "OMSServer:1,2",
                "SlapdServer:1,2",
                "KerberosServer:1,2",
                "KerberosAdmin:1,2",
                "quorumpeer:1,2,3",
                "NameNode:2,3",
                "Zkfc:2,3",
                "JournalNode:1,2,3",
                "ResourceManager:2,3",
                "JobHistoryServer:2,3",
                "DBServer:1,3",
                "Hue:1,3",
                "LoaderServer:1,3",
                "MetaStore:1,2,3",
                "WebHCat:1,2,3",
                "HiveServer:1,2,3",
                "HMaster:2,3",
                "MonitorServer:1,2",
                "Nimbus:1,2",
                "UI:1,2",
                "JDBCServer2x:1,2,3",
                "JobHistory2x:2,3",
                "SparkResource2x:1,2,3",
                "oozie:2,3",
                "LoadBalancer:2,3",
                "TezUI:1,3",
                "TimelineServer:3",
                "RangerAdmin:1,2",
                "UserSync:2",
                "TagSync:2",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "HSConsole:2,3",
                "FlinkResource:1,2,3",
                "DataNode:1,2,3",
                "NodeManager:1,2,3",
                "IndexServer2x:1,2",
                "ThriftServer:1,2,3",
                "RegionServer:1,2,3",
                "ThriftServer1:1,2,3",
                "RESTServer:1,2,3",
                "Broker:1,2,3",
                "Supervisor:1,2,3",
                "Logviewer:1,2,3",
                "Flume:1,2,3",
                "HSBroker:1,2,3"
            ]
            dataVolumeNodeGroups2 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups2 = Volume(
                type="SAS",
                size=480
            )
            listNodeGroupsbody = [
                NodeGroupV2(
                    group_name="master_node_default_group",
                    node_num=3,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups2,
                    data_volume=dataVolumeNodeGroups2,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups2
                ),
                NodeGroupV2(
                    group_name="node_group_1",
                    node_num=3,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups1,
                    data_volume=dataVolumeNodeGroups1,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups1
                ),
                NodeGroupV2(
                    group_name="node_group_2",
                    node_num=1,
                    node_size="Sit3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups,
                    data_volume=dataVolumeNodeGroups,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups
                )
            ]
            listTagsbody = [
                Tag(
                    key="tag1",
                    value="111"
                ),
                Tag(
                    key="tag2",
                    value="222"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            request.body = CreateClusterReqV2(
                node_groups=listNodeGroupsbody,
                log_collection=1,
                tags=listTagsbody,
                template_id="mgmt_control_combined_v2",
                mrs_ecs_default_agency="MRS_ECS_DEFAULT_AGENCY",
                node_root_password="your password",
                login_mode="PASSWORD",
                manager_admin_password="your password",
                safe_mode="KERBEROS",
                availability_zone="",
                components="Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
                subnet_name="subnet",
                subnet_id="1f8c5ca6-1f66-4096-bb00-baf175954f6e",
                vpc_name="vpc-37cd",
                region="",
                charge_info=chargeInfobody,
                cluster_type="CUSTOM",
                cluster_name="mrs_heshe_dm",
                cluster_version="MRS 3.1.0"
            )
            response = client.create_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a custom cluster where management and control nodes are separated, with cluster version MRS 3.1.0. The cluster contains one Master node group with five nodes and one Core node group with three nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    # 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 = CreateClusterRequest()
            listAssignedRolesNodeGroups = [
                "DataNode",
                "NodeManager",
                "RegionServer",
                "Flume:1",
                "Broker",
                "Supervisor",
                "Logviewer",
                "HBaseIndexer",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "HSBroker:1,2",
                "ThriftServer",
                "ThriftServer1",
                "RESTServer",
                "FlinkResource"
            ]
            dataVolumeNodeGroups = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups1 = [
                "OMSServer:1,2",
                "SlapdServer:3,4",
                "KerberosServer:3,4",
                "KerberosAdmin:3,4",
                "quorumpeer:3,4,5",
                "NameNode:4,5",
                "Zkfc:4,5",
                "JournalNode:1,2,3,4,5",
                "ResourceManager:4,5",
                "JobHistoryServer:4,5",
                "DBServer:3,5",
                "Hue:1,2",
                "LoaderServer:1,2",
                "MetaStore:1,2,3,4,5",
                "WebHCat:1,2,3,4,5",
                "HiveServer:1,2,3,4,5",
                "HMaster:4,5",
                "MonitorServer:1,2",
                "Nimbus:1,2",
                "UI:1,2",
                "JDBCServer2x:1,2,3,4,5",
                "JobHistory2x:4,5",
                "SparkResource2x:1,2,3,4,5",
                "oozie:1,2",
                "LoadBalancer:1,2",
                "TezUI:1,2",
                "TimelineServer:5",
                "RangerAdmin:1,2",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "HSConsole:1,2",
                "FlinkResource:1,2,3,4,5",
                "DataNode:1,2,3,4,5",
                "NodeManager:1,2,3,4,5",
                "IndexServer2x:1,2",
                "ThriftServer:1,2,3,4,5",
                "RegionServer:1,2,3,4,5",
                "ThriftServer1:1,2,3,4,5",
                "RESTServer:1,2,3,4,5",
                "Broker:1,2,3,4,5",
                "Supervisor:1,2,3,4,5",
                "Logviewer:1,2,3,4,5",
                "Flume:1,2,3,4,5",
                "HBaseIndexer:1,2,3,4,5",
                "TagSync:1",
                "UserSync:1"
            ]
            dataVolumeNodeGroups1 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups1 = Volume(
                type="SAS",
                size=480
            )
            listNodeGroupsbody = [
                NodeGroupV2(
                    group_name="master_node_default_group",
                    node_num=5,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups1,
                    data_volume=dataVolumeNodeGroups1,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups1
                ),
                NodeGroupV2(
                    group_name="node_group_1",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups,
                    data_volume=dataVolumeNodeGroups,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups
                )
            ]
            listTagsbody = [
                Tag(
                    key="aaa",
                    value="111"
                ),
                Tag(
                    key="bbb",
                    value="222"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            request.body = CreateClusterReqV2(
                node_groups=listNodeGroupsbody,
                log_collection=1,
                tags=listTagsbody,
                template_id="mgmt_control_separated_v2",
                mrs_ecs_default_agency="MRS_ECS_DEFAULT_AGENCY",
                node_root_password="your password",
                login_mode="PASSWORD",
                manager_admin_password="your password",
                safe_mode="KERBEROS",
                availability_zone="",
                components="Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
                subnet_name="subnet",
                subnet_id="1f8c5ca6-1f66-4096-bb00-baf175954f6e",
                vpc_name="vpc-37cd",
                region="",
                charge_info=chargeInfobody,
                cluster_type="CUSTOM",
                cluster_name="mrs_jdRU_dm01",
                cluster_version="MRS 3.1.0"
            )
            response = client.create_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a custom cluster where data nodes are deployed separately, with cluster version MRS 3.1.0. The cluster contains one Master node group with nine nodes and four Core node groups, each with three nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    # 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 = CreateClusterRequest()
            listAssignedRolesNodeGroups = [
                "Broker",
                "Supervisor",
                "Logviewer",
                "KerberosClient",
                "SlapdClient",
                "meta"
            ]
            dataVolumeNodeGroups = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups1 = [
                "KerberosClient",
                "SlapdClient",
                "meta"
            ]
            dataVolumeNodeGroups1 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups1 = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups2 = [
                "HBaseIndexer",
                "SolrServer[3]",
                "EsNode[2]",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "SolrServerAdmin:1,2"
            ]
            dataVolumeNodeGroups2 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups2 = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups3 = [
                "DataNode",
                "NodeManager",
                "RegionServer",
                "Flume:1",
                "GraphServer",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "HSBroker:1,2"
            ]
            dataVolumeNodeGroups3 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups3 = Volume(
                type="SAS",
                size=480
            )
            listAssignedRolesNodeGroups4 = [
                "OMSServer:1,2",
                "SlapdServer:5,6",
                "KerberosServer:5,6",
                "KerberosAdmin:5,6",
                "quorumpeer:5,6,7,8,9",
                "NameNode:3,4",
                "Zkfc:3,4",
                "JournalNode:5,6,7",
                "ResourceManager:8,9",
                "JobHistoryServer:8",
                "DBServer:8,9",
                "Hue:8,9",
                "FlinkResource:3,4",
                "LoaderServer:3,5",
                "MetaStore:8,9",
                "WebHCat:5",
                "HiveServer:8,9",
                "HMaster:8,9",
                "FTP-Server:3,4",
                "MonitorServer:3,4",
                "Nimbus:8,9",
                "UI:8,9",
                "JDBCServer2x:8,9",
                "JobHistory2x:8,9",
                "SparkResource2x:5,6,7",
                "oozie:4,5",
                "EsMaster:7,8,9",
                "LoadBalancer:8,9",
                "TezUI:5,6",
                "TimelineServer:5",
                "RangerAdmin:4,5",
                "UserSync:5",
                "TagSync:5",
                "KerberosClient",
                "SlapdClient",
                "meta",
                "HSBroker:5",
                "HSConsole:3,4",
                "FlinkResource:3,4"
            ]
            dataVolumeNodeGroups4 = Volume(
                type="SAS",
                size=600
            )
            rootVolumeNodeGroups4 = Volume(
                type="SAS",
                size=480
            )
            listNodeGroupsbody = [
                NodeGroupV2(
                    group_name="master_node_default_group",
                    node_num=9,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups4,
                    data_volume=dataVolumeNodeGroups4,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups4
                ),
                NodeGroupV2(
                    group_name="node_group_1",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups3,
                    data_volume=dataVolumeNodeGroups3,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups3
                ),
                NodeGroupV2(
                    group_name="node_group_2",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups2,
                    data_volume=dataVolumeNodeGroups2,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups2
                ),
                NodeGroupV2(
                    group_name="node_group_3",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups1,
                    data_volume=dataVolumeNodeGroups1,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups1
                ),
                NodeGroupV2(
                    group_name="node_group_4",
                    node_num=3,
                    node_size="rc3.4xlarge.4.linux.bigdata",
                    root_volume=rootVolumeNodeGroups,
                    data_volume=dataVolumeNodeGroups,
                    data_volume_count=1,
                    assigned_roles=listAssignedRolesNodeGroups
                )
            ]
            listTagsbody = [
                Tag(
                    key="aaa",
                    value="111"
                ),
                Tag(
                    key="bbb",
                    value="222"
                )
            ]
            chargeInfobody = ChargeInfo(
                charge_mode="postPaid"
            )
            request.body = CreateClusterReqV2(
                node_groups=listNodeGroupsbody,
                log_collection=1,
                tags=listTagsbody,
                template_id="mgmt_control_data_separated_v2",
                mrs_ecs_default_agency="MRS_ECS_DEFAULT_AGENCY",
                node_root_password="your password",
                login_mode="PASSWORD",
                manager_admin_password="your password",
                safe_mode="KERBEROS",
                availability_zone="",
                components="Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
                subnet_name="subnet",
                subnet_id="1f8c5ca6-1f66-4096-bb00-baf175954f6e",
                vpc_name="vpc-37cd",
                region="",
                charge_info=chargeInfobody,
                cluster_type="CUSTOM",
                cluster_name="mrs_jdRU_dm02",
                cluster_version="MRS 3.1.0"
            )
            response = client.create_cluster(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create an analysis cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with three nodes. Autoscaling is enabled every Monday from 12:00 to 13:00. The initial configuration hive.union.data.type.incompatible.enable of the Hive component is changed to true, and dfs.replication is changed to 4.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    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.CreateClusterRequest{}
    	var listConfigsComponentConfigs = []model.Config{
            {
                Key: "hive.union.data.type.incompatible.enable",
                Value: "true",
                ConfigFileName: "hive-site.xml",
            },
            {
                Key: "dfs.replication",
                Value: "4",
                ConfigFileName: "hdfs-site.xml",
            },
        }
    	var listComponentConfigsbody = []model.ComponentConfig{
            {
                ComponentName: "Hive",
                Configs: &listConfigsComponentConfigs,
            },
        }
    	var listNodesExecScripts = []string{
            "master_node_default_group",
    	    "core_node_analysis_group",
    	    "task_node_analysis_group",
        }
    	parametersExecScripts:= ""
    	activeMasterExecScripts:= false
    	var listExecScriptsAutoScalingPolicy = []model.ScaleScript{
            {
                Name: "test",
                Uri: "s3a://obs-mrstest/bootstrap/basic_success.sh",
                Parameters: &parametersExecScripts,
                Nodes: listNodesExecScripts,
                ActiveMaster: &activeMasterExecScripts,
                FailAction: model.GetScaleScriptFailActionEnum().CONTINUE,
                ActionStage: model.GetScaleScriptActionStageEnum().BEFORE_SCALE_OUT,
            },
        }
    	comparisonOperatorTrigger:= "GTOE"
    	triggerRules := &model.Trigger{
    		MetricName: "YARNAppRunning",
    		MetricValue: "100",
    		ComparisonOperator: &comparisonOperatorTrigger,
    		EvaluationPeriods: int32(1),
    	}
    	descriptionRules:= ""
    	var listRulesAutoScalingPolicy = []model.Rule{
            {
                Name: "default-expand-1",
                Description: &descriptionRules,
                AdjustmentType: model.GetRuleAdjustmentTypeEnum().SCALE_OUT,
                CoolDownMinutes: int32(5),
                ScalingAdjustment: int32(1),
                Trigger: triggerRules,
            },
        }
    	var listEffectiveDaysResourcesPlans = []model.ResourcesPlanEffectiveDays{
            model.GetResourcesPlanEffectiveDaysEnum().MONDAY,
        }
    	var listResourcesPlansAutoScalingPolicy = []model.ResourcesPlan{
            {
                PeriodType: "daily",
                StartTime: "12:00",
                EndTime: "13:00",
                MinCapacity: int32(2),
                MaxCapacity: int32(3),
                EffectiveDays: &listEffectiveDaysResourcesPlans,
            },
        }
    	autoScalingPolicyNodeGroups := &model.AutoScalingPolicy{
    		AutoScalingEnable: true,
    		MinCapacity: int32(0),
    		MaxCapacity: int32(1),
    		ResourcesPlans: &listResourcesPlansAutoScalingPolicy,
    		Rules: &listRulesAutoScalingPolicy,
    		ExecScripts: &listExecScriptsAutoScalingPolicy,
    	}
    	dataVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeCountNodeGroups:= int32(1)
    	dataVolumeCountNodeGroups1:= int32(1)
    	dataVolumeCountNodeGroups2:= int32(1)
    	var listNodeGroupsbody = []model.NodeGroupV2{
            {
                GroupName: "master_node_default_group",
                NodeNum: int32(2),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups2,
                DataVolume: dataVolumeNodeGroups2,
                DataVolumeCount: &dataVolumeCountNodeGroups,
            },
            {
                GroupName: "core_node_analysis_group",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups1,
                DataVolume: dataVolumeNodeGroups1,
                DataVolumeCount: &dataVolumeCountNodeGroups1,
            },
            {
                GroupName: "task_node_analysis_group",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups,
                DataVolume: dataVolumeNodeGroups,
                DataVolumeCount: &dataVolumeCountNodeGroups2,
                AutoScalingPolicy: autoScalingPolicyNodeGroups,
            },
        }
    	var listTagsbody = []model.Tag{
            {
                Key: "tag1",
                Value: "111",
            },
            {
                Key: "tag2",
                Value: "222",
            },
        }
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	logCollectionCreateClusterReqV2:= model.GetCreateClusterReqV2LogCollectionEnum().E_1
    	mrsEcsDefaultAgencyCreateClusterReqV2:= "MRS_ECS_DEFAULT_AGENCY"
    	nodeRootPasswordCreateClusterReqV2:= "your password"
    	subnetIdCreateClusterReqV2:= "1f8c5ca6-1f66-4096-bb00-baf175954f6e"
    	request.Body = &model.CreateClusterReqV2{
    		ComponentConfigs: &listComponentConfigsbody,
    		NodeGroups: listNodeGroupsbody,
    		LogCollection: &logCollectionCreateClusterReqV2,
    		Tags: &listTagsbody,
    		MrsEcsDefaultAgency: &mrsEcsDefaultAgencyCreateClusterReqV2,
    		NodeRootPassword: &nodeRootPasswordCreateClusterReqV2,
    		LoginMode: "PASSWORD",
    		ManagerAdminPassword: "your password",
    		SafeMode: "KERBEROS",
    		AvailabilityZone: "",
    		Components: "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Flink,Oozie,Ranger,Tez",
    		SubnetName: "subnet",
    		SubnetId: &subnetIdCreateClusterReqV2,
    		VpcName: "vpc-37cd",
    		Region: "",
    		ChargeInfo: chargeInfobody,
    		ClusterType: "ANALYSIS",
    		ClusterName: "mrs_DyJA_dm",
    		ClusterVersion: "MRS 3.1.0",
    	}
    	response, err := client.CreateCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a streaming cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, one Core node group with three nodes, and one Task node group with zero nodes. Autoscaling is enabled every Monday from 12:00 to 13:00.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    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.CreateClusterRequest{}
    	comparisonOperatorTrigger:= "LTOE"
    	triggerRules := &model.Trigger{
    		MetricName: "StormSlotAvailablePercentage",
    		MetricValue: "100",
    		ComparisonOperator: &comparisonOperatorTrigger,
    		EvaluationPeriods: int32(1),
    	}
    	descriptionRules:= ""
    	var listRulesAutoScalingPolicy = []model.Rule{
            {
                Name: "default-expand-1",
                Description: &descriptionRules,
                AdjustmentType: model.GetRuleAdjustmentTypeEnum().SCALE_OUT,
                CoolDownMinutes: int32(5),
                ScalingAdjustment: int32(1),
                Trigger: triggerRules,
            },
        }
    	var listEffectiveDaysResourcesPlans = []model.ResourcesPlanEffectiveDays{
            model.GetResourcesPlanEffectiveDaysEnum().MONDAY,
        }
    	var listResourcesPlansAutoScalingPolicy = []model.ResourcesPlan{
            {
                PeriodType: "daily",
                StartTime: "12:00",
                EndTime: "13:00",
                MinCapacity: int32(2),
                MaxCapacity: int32(3),
                EffectiveDays: &listEffectiveDaysResourcesPlans,
            },
        }
    	autoScalingPolicyNodeGroups := &model.AutoScalingPolicy{
    		AutoScalingEnable: true,
    		MinCapacity: int32(0),
    		MaxCapacity: int32(1),
    		ResourcesPlans: &listResourcesPlansAutoScalingPolicy,
    		Rules: &listRulesAutoScalingPolicy,
    	}
    	dataVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeCountNodeGroups:= int32(1)
    	dataVolumeCountNodeGroups1:= int32(1)
    	dataVolumeCountNodeGroups2:= int32(1)
    	var listNodeGroupsbody = []model.NodeGroupV2{
            {
                GroupName: "master_node_default_group",
                NodeNum: int32(2),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups2,
                DataVolume: dataVolumeNodeGroups2,
                DataVolumeCount: &dataVolumeCountNodeGroups,
            },
            {
                GroupName: "core_node_streaming_group",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups1,
                DataVolume: dataVolumeNodeGroups1,
                DataVolumeCount: &dataVolumeCountNodeGroups1,
            },
            {
                GroupName: "task_node_streaming_group",
                NodeNum: int32(0),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups,
                DataVolume: dataVolumeNodeGroups,
                DataVolumeCount: &dataVolumeCountNodeGroups2,
                AutoScalingPolicy: autoScalingPolicyNodeGroups,
            },
        }
    	var listTagsbody = []model.Tag{
            {
                Key: "tag1",
                Value: "111",
            },
            {
                Key: "tag2",
                Value: "222",
            },
        }
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	logCollectionCreateClusterReqV2:= model.GetCreateClusterReqV2LogCollectionEnum().E_1
    	mrsEcsDefaultAgencyCreateClusterReqV2:= "MRS_ECS_DEFAULT_AGENCY"
    	nodeRootPasswordCreateClusterReqV2:= "your password"
    	subnetIdCreateClusterReqV2:= "1f8c5ca6-1f66-4096-bb00-baf175954f6e"
    	request.Body = &model.CreateClusterReqV2{
    		NodeGroups: listNodeGroupsbody,
    		LogCollection: &logCollectionCreateClusterReqV2,
    		Tags: &listTagsbody,
    		MrsEcsDefaultAgency: &mrsEcsDefaultAgencyCreateClusterReqV2,
    		NodeRootPassword: &nodeRootPasswordCreateClusterReqV2,
    		LoginMode: "PASSWORD",
    		ManagerAdminPassword: "your password",
    		SafeMode: "KERBEROS",
    		AvailabilityZone: "",
    		Components: "Storm,Kafka,Flume,Ranger",
    		SubnetName: "subnet",
    		SubnetId: &subnetIdCreateClusterReqV2,
    		VpcName: "vpc-37cd",
    		Region: "",
    		ChargeInfo: chargeInfobody,
    		ClusterType: "STREAMING",
    		ClusterName: "mrs_Dokle_dm",
    		ClusterVersion: "MRS 3.1.0",
    	}
    	response, err := client.CreateCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a hybrid cluster with cluster version MRS 3.1.0. The cluster contains one Master node group with two nodes, two Core node groups with three nodes each, and two Task node groups — one with one node and the other with zero nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    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.CreateClusterRequest{}
    	dataVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups3 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups3 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeNodeGroups4 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups4 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeCountNodeGroups:= int32(1)
    	dataVolumeCountNodeGroups1:= int32(1)
    	dataVolumeCountNodeGroups2:= int32(1)
    	dataVolumeCountNodeGroups3:= int32(1)
    	dataVolumeCountNodeGroups4:= int32(1)
    	var listNodeGroupsbody = []model.NodeGroupV2{
            {
                GroupName: "master_node_default_group",
                NodeNum: int32(2),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups4,
                DataVolume: dataVolumeNodeGroups4,
                DataVolumeCount: &dataVolumeCountNodeGroups,
            },
            {
                GroupName: "core_node_streaming_group",
                NodeNum: int32(3),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups3,
                DataVolume: dataVolumeNodeGroups3,
                DataVolumeCount: &dataVolumeCountNodeGroups1,
            },
            {
                GroupName: "core_node_analysis_group",
                NodeNum: int32(3),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups2,
                DataVolume: dataVolumeNodeGroups2,
                DataVolumeCount: &dataVolumeCountNodeGroups2,
            },
            {
                GroupName: "task_node_analysis_group",
                NodeNum: int32(1),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups1,
                DataVolume: dataVolumeNodeGroups1,
                DataVolumeCount: &dataVolumeCountNodeGroups3,
            },
            {
                GroupName: "task_node_streaming_group",
                NodeNum: int32(0),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups,
                DataVolume: dataVolumeNodeGroups,
                DataVolumeCount: &dataVolumeCountNodeGroups4,
            },
        }
    	var listTagsbody = []model.Tag{
            {
                Key: "tag1",
                Value: "111",
            },
            {
                Key: "tag2",
                Value: "222",
            },
        }
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	logCollectionCreateClusterReqV2:= model.GetCreateClusterReqV2LogCollectionEnum().E_1
    	mrsEcsDefaultAgencyCreateClusterReqV2:= "MRS_ECS_DEFAULT_AGENCY"
    	nodeRootPasswordCreateClusterReqV2:= "your password"
    	subnetIdCreateClusterReqV2:= "1f8c5ca6-1f66-4096-bb00-baf175954f6e"
    	request.Body = &model.CreateClusterReqV2{
    		NodeGroups: listNodeGroupsbody,
    		LogCollection: &logCollectionCreateClusterReqV2,
    		Tags: &listTagsbody,
    		MrsEcsDefaultAgency: &mrsEcsDefaultAgencyCreateClusterReqV2,
    		NodeRootPassword: &nodeRootPasswordCreateClusterReqV2,
    		LoginMode: "PASSWORD",
    		ManagerAdminPassword: "your password",
    		SafeMode: "KERBEROS",
    		AvailabilityZone: "",
    		Components: "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
    		SubnetName: "subnet",
    		SubnetId: &subnetIdCreateClusterReqV2,
    		VpcName: "vpc-37cd",
    		Region: "",
    		ChargeInfo: chargeInfobody,
    		ClusterType: "MIXED",
    		ClusterName: "mrs_onmm_dm",
    		ClusterVersion: "MRS 3.1.0",
    	}
    	response, err := client.CreateCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a custom cluster where management and control nodes are co-located, with cluster version MRS 3.1.0. The cluster contains one Master node group with three nodes, and two Core node groups — one with three nodes and the other with one node.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    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.CreateClusterRequest{}
    	var listAssignedRolesNodeGroups = []string{
            "NodeManager",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "FlinkResource",
        }
    	dataVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups1 = []string{
            "DataNode",
    	    "NodeManager",
    	    "RegionServer",
    	    "Flume:1",
    	    "Broker",
    	    "Supervisor",
    	    "Logviewer",
    	    "HBaseIndexer",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "HSBroker:1,2",
    	    "ThriftServer",
    	    "ThriftServer1",
    	    "RESTServer",
    	    "FlinkResource",
        }
    	dataVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups2 = []string{
            "OMSServer:1,2",
    	    "SlapdServer:1,2",
    	    "KerberosServer:1,2",
    	    "KerberosAdmin:1,2",
    	    "quorumpeer:1,2,3",
    	    "NameNode:2,3",
    	    "Zkfc:2,3",
    	    "JournalNode:1,2,3",
    	    "ResourceManager:2,3",
    	    "JobHistoryServer:2,3",
    	    "DBServer:1,3",
    	    "Hue:1,3",
    	    "LoaderServer:1,3",
    	    "MetaStore:1,2,3",
    	    "WebHCat:1,2,3",
    	    "HiveServer:1,2,3",
    	    "HMaster:2,3",
    	    "MonitorServer:1,2",
    	    "Nimbus:1,2",
    	    "UI:1,2",
    	    "JDBCServer2x:1,2,3",
    	    "JobHistory2x:2,3",
    	    "SparkResource2x:1,2,3",
    	    "oozie:2,3",
    	    "LoadBalancer:2,3",
    	    "TezUI:1,3",
    	    "TimelineServer:3",
    	    "RangerAdmin:1,2",
    	    "UserSync:2",
    	    "TagSync:2",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "HSConsole:2,3",
    	    "FlinkResource:1,2,3",
    	    "DataNode:1,2,3",
    	    "NodeManager:1,2,3",
    	    "IndexServer2x:1,2",
    	    "ThriftServer:1,2,3",
    	    "RegionServer:1,2,3",
    	    "ThriftServer1:1,2,3",
    	    "RESTServer:1,2,3",
    	    "Broker:1,2,3",
    	    "Supervisor:1,2,3",
    	    "Logviewer:1,2,3",
    	    "Flume:1,2,3",
    	    "HSBroker:1,2,3",
        }
    	dataVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeCountNodeGroups:= int32(1)
    	dataVolumeCountNodeGroups1:= int32(1)
    	dataVolumeCountNodeGroups2:= int32(1)
    	var listNodeGroupsbody = []model.NodeGroupV2{
            {
                GroupName: "master_node_default_group",
                NodeNum: int32(3),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups2,
                DataVolume: dataVolumeNodeGroups2,
                DataVolumeCount: &dataVolumeCountNodeGroups,
                AssignedRoles: &listAssignedRolesNodeGroups2,
            },
            {
                GroupName: "node_group_1",
                NodeNum: int32(3),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups1,
                DataVolume: dataVolumeNodeGroups1,
                DataVolumeCount: &dataVolumeCountNodeGroups1,
                AssignedRoles: &listAssignedRolesNodeGroups1,
            },
            {
                GroupName: "node_group_2",
                NodeNum: int32(1),
                NodeSize: "Sit3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups,
                DataVolume: dataVolumeNodeGroups,
                DataVolumeCount: &dataVolumeCountNodeGroups2,
                AssignedRoles: &listAssignedRolesNodeGroups,
            },
        }
    	var listTagsbody = []model.Tag{
            {
                Key: "tag1",
                Value: "111",
            },
            {
                Key: "tag2",
                Value: "222",
            },
        }
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	logCollectionCreateClusterReqV2:= model.GetCreateClusterReqV2LogCollectionEnum().E_1
    	templateIdCreateClusterReqV2:= "mgmt_control_combined_v2"
    	mrsEcsDefaultAgencyCreateClusterReqV2:= "MRS_ECS_DEFAULT_AGENCY"
    	nodeRootPasswordCreateClusterReqV2:= "your password"
    	subnetIdCreateClusterReqV2:= "1f8c5ca6-1f66-4096-bb00-baf175954f6e"
    	request.Body = &model.CreateClusterReqV2{
    		NodeGroups: listNodeGroupsbody,
    		LogCollection: &logCollectionCreateClusterReqV2,
    		Tags: &listTagsbody,
    		TemplateId: &templateIdCreateClusterReqV2,
    		MrsEcsDefaultAgency: &mrsEcsDefaultAgencyCreateClusterReqV2,
    		NodeRootPassword: &nodeRootPasswordCreateClusterReqV2,
    		LoginMode: "PASSWORD",
    		ManagerAdminPassword: "your password",
    		SafeMode: "KERBEROS",
    		AvailabilityZone: "",
    		Components: "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
    		SubnetName: "subnet",
    		SubnetId: &subnetIdCreateClusterReqV2,
    		VpcName: "vpc-37cd",
    		Region: "",
    		ChargeInfo: chargeInfobody,
    		ClusterType: "CUSTOM",
    		ClusterName: "mrs_heshe_dm",
    		ClusterVersion: "MRS 3.1.0",
    	}
    	response, err := client.CreateCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a custom cluster where management and control nodes are separated, with cluster version MRS 3.1.0. The cluster contains one Master node group with five nodes and one Core node group with three nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    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.CreateClusterRequest{}
    	var listAssignedRolesNodeGroups = []string{
            "DataNode",
    	    "NodeManager",
    	    "RegionServer",
    	    "Flume:1",
    	    "Broker",
    	    "Supervisor",
    	    "Logviewer",
    	    "HBaseIndexer",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "HSBroker:1,2",
    	    "ThriftServer",
    	    "ThriftServer1",
    	    "RESTServer",
    	    "FlinkResource",
        }
    	dataVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups1 = []string{
            "OMSServer:1,2",
    	    "SlapdServer:3,4",
    	    "KerberosServer:3,4",
    	    "KerberosAdmin:3,4",
    	    "quorumpeer:3,4,5",
    	    "NameNode:4,5",
    	    "Zkfc:4,5",
    	    "JournalNode:1,2,3,4,5",
    	    "ResourceManager:4,5",
    	    "JobHistoryServer:4,5",
    	    "DBServer:3,5",
    	    "Hue:1,2",
    	    "LoaderServer:1,2",
    	    "MetaStore:1,2,3,4,5",
    	    "WebHCat:1,2,3,4,5",
    	    "HiveServer:1,2,3,4,5",
    	    "HMaster:4,5",
    	    "MonitorServer:1,2",
    	    "Nimbus:1,2",
    	    "UI:1,2",
    	    "JDBCServer2x:1,2,3,4,5",
    	    "JobHistory2x:4,5",
    	    "SparkResource2x:1,2,3,4,5",
    	    "oozie:1,2",
    	    "LoadBalancer:1,2",
    	    "TezUI:1,2",
    	    "TimelineServer:5",
    	    "RangerAdmin:1,2",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "HSConsole:1,2",
    	    "FlinkResource:1,2,3,4,5",
    	    "DataNode:1,2,3,4,5",
    	    "NodeManager:1,2,3,4,5",
    	    "IndexServer2x:1,2",
    	    "ThriftServer:1,2,3,4,5",
    	    "RegionServer:1,2,3,4,5",
    	    "ThriftServer1:1,2,3,4,5",
    	    "RESTServer:1,2,3,4,5",
    	    "Broker:1,2,3,4,5",
    	    "Supervisor:1,2,3,4,5",
    	    "Logviewer:1,2,3,4,5",
    	    "Flume:1,2,3,4,5",
    	    "HBaseIndexer:1,2,3,4,5",
    	    "TagSync:1",
    	    "UserSync:1",
        }
    	dataVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeCountNodeGroups:= int32(1)
    	dataVolumeCountNodeGroups1:= int32(1)
    	var listNodeGroupsbody = []model.NodeGroupV2{
            {
                GroupName: "master_node_default_group",
                NodeNum: int32(5),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups1,
                DataVolume: dataVolumeNodeGroups1,
                DataVolumeCount: &dataVolumeCountNodeGroups,
                AssignedRoles: &listAssignedRolesNodeGroups1,
            },
            {
                GroupName: "node_group_1",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups,
                DataVolume: dataVolumeNodeGroups,
                DataVolumeCount: &dataVolumeCountNodeGroups1,
                AssignedRoles: &listAssignedRolesNodeGroups,
            },
        }
    	var listTagsbody = []model.Tag{
            {
                Key: "aaa",
                Value: "111",
            },
            {
                Key: "bbb",
                Value: "222",
            },
        }
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	logCollectionCreateClusterReqV2:= model.GetCreateClusterReqV2LogCollectionEnum().E_1
    	templateIdCreateClusterReqV2:= "mgmt_control_separated_v2"
    	mrsEcsDefaultAgencyCreateClusterReqV2:= "MRS_ECS_DEFAULT_AGENCY"
    	nodeRootPasswordCreateClusterReqV2:= "your password"
    	subnetIdCreateClusterReqV2:= "1f8c5ca6-1f66-4096-bb00-baf175954f6e"
    	request.Body = &model.CreateClusterReqV2{
    		NodeGroups: listNodeGroupsbody,
    		LogCollection: &logCollectionCreateClusterReqV2,
    		Tags: &listTagsbody,
    		TemplateId: &templateIdCreateClusterReqV2,
    		MrsEcsDefaultAgency: &mrsEcsDefaultAgencyCreateClusterReqV2,
    		NodeRootPassword: &nodeRootPasswordCreateClusterReqV2,
    		LoginMode: "PASSWORD",
    		ManagerAdminPassword: "your password",
    		SafeMode: "KERBEROS",
    		AvailabilityZone: "",
    		Components: "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
    		SubnetName: "subnet",
    		SubnetId: &subnetIdCreateClusterReqV2,
    		VpcName: "vpc-37cd",
    		Region: "",
    		ChargeInfo: chargeInfobody,
    		ClusterType: "CUSTOM",
    		ClusterName: "mrs_jdRU_dm01",
    		ClusterVersion: "MRS 3.1.0",
    	}
    	response, err := client.CreateCluster(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a custom cluster where data nodes are deployed separately, with cluster version MRS 3.1.0. The cluster contains one Master node group with nine nodes and four Core node groups, each with three nodes.

      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
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    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.CreateClusterRequest{}
    	var listAssignedRolesNodeGroups = []string{
            "Broker",
    	    "Supervisor",
    	    "Logviewer",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
        }
    	dataVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups1 = []string{
            "KerberosClient",
    	    "SlapdClient",
    	    "meta",
        }
    	dataVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups1 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups2 = []string{
            "HBaseIndexer",
    	    "SolrServer[3]",
    	    "EsNode[2]",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "SolrServerAdmin:1,2",
        }
    	dataVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups2 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups3 = []string{
            "DataNode",
    	    "NodeManager",
    	    "RegionServer",
    	    "Flume:1",
    	    "GraphServer",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "HSBroker:1,2",
        }
    	dataVolumeNodeGroups3 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups3 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	var listAssignedRolesNodeGroups4 = []string{
            "OMSServer:1,2",
    	    "SlapdServer:5,6",
    	    "KerberosServer:5,6",
    	    "KerberosAdmin:5,6",
    	    "quorumpeer:5,6,7,8,9",
    	    "NameNode:3,4",
    	    "Zkfc:3,4",
    	    "JournalNode:5,6,7",
    	    "ResourceManager:8,9",
    	    "JobHistoryServer:8",
    	    "DBServer:8,9",
    	    "Hue:8,9",
    	    "FlinkResource:3,4",
    	    "LoaderServer:3,5",
    	    "MetaStore:8,9",
    	    "WebHCat:5",
    	    "HiveServer:8,9",
    	    "HMaster:8,9",
    	    "FTP-Server:3,4",
    	    "MonitorServer:3,4",
    	    "Nimbus:8,9",
    	    "UI:8,9",
    	    "JDBCServer2x:8,9",
    	    "JobHistory2x:8,9",
    	    "SparkResource2x:5,6,7",
    	    "oozie:4,5",
    	    "EsMaster:7,8,9",
    	    "LoadBalancer:8,9",
    	    "TezUI:5,6",
    	    "TimelineServer:5",
    	    "RangerAdmin:4,5",
    	    "UserSync:5",
    	    "TagSync:5",
    	    "KerberosClient",
    	    "SlapdClient",
    	    "meta",
    	    "HSBroker:5",
    	    "HSConsole:3,4",
    	    "FlinkResource:3,4",
        }
    	dataVolumeNodeGroups4 := &model.Volume{
    		Type: "SAS",
    		Size: int32(600),
    	}
    	rootVolumeNodeGroups4 := &model.Volume{
    		Type: "SAS",
    		Size: int32(480),
    	}
    	dataVolumeCountNodeGroups:= int32(1)
    	dataVolumeCountNodeGroups1:= int32(1)
    	dataVolumeCountNodeGroups2:= int32(1)
    	dataVolumeCountNodeGroups3:= int32(1)
    	dataVolumeCountNodeGroups4:= int32(1)
    	var listNodeGroupsbody = []model.NodeGroupV2{
            {
                GroupName: "master_node_default_group",
                NodeNum: int32(9),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups4,
                DataVolume: dataVolumeNodeGroups4,
                DataVolumeCount: &dataVolumeCountNodeGroups,
                AssignedRoles: &listAssignedRolesNodeGroups4,
            },
            {
                GroupName: "node_group_1",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups3,
                DataVolume: dataVolumeNodeGroups3,
                DataVolumeCount: &dataVolumeCountNodeGroups1,
                AssignedRoles: &listAssignedRolesNodeGroups3,
            },
            {
                GroupName: "node_group_2",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups2,
                DataVolume: dataVolumeNodeGroups2,
                DataVolumeCount: &dataVolumeCountNodeGroups2,
                AssignedRoles: &listAssignedRolesNodeGroups2,
            },
            {
                GroupName: "node_group_3",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups1,
                DataVolume: dataVolumeNodeGroups1,
                DataVolumeCount: &dataVolumeCountNodeGroups3,
                AssignedRoles: &listAssignedRolesNodeGroups1,
            },
            {
                GroupName: "node_group_4",
                NodeNum: int32(3),
                NodeSize: "rc3.4xlarge.4.linux.bigdata",
                RootVolume: rootVolumeNodeGroups,
                DataVolume: dataVolumeNodeGroups,
                DataVolumeCount: &dataVolumeCountNodeGroups4,
                AssignedRoles: &listAssignedRolesNodeGroups,
            },
        }
    	var listTagsbody = []model.Tag{
            {
                Key: "aaa",
                Value: "111",
            },
            {
                Key: "bbb",
                Value: "222",
            },
        }
    	chargeInfobody := &model.ChargeInfo{
    		ChargeMode: "postPaid",
    	}
    	logCollectionCreateClusterReqV2:= model.GetCreateClusterReqV2LogCollectionEnum().E_1
    	templateIdCreateClusterReqV2:= "mgmt_control_data_separated_v2"
    	mrsEcsDefaultAgencyCreateClusterReqV2:= "MRS_ECS_DEFAULT_AGENCY"
    	nodeRootPasswordCreateClusterReqV2:= "your password"
    	subnetIdCreateClusterReqV2:= "1f8c5ca6-1f66-4096-bb00-baf175954f6e"
    	request.Body = &model.CreateClusterReqV2{
    		NodeGroups: listNodeGroupsbody,
    		LogCollection: &logCollectionCreateClusterReqV2,
    		Tags: &listTagsbody,
    		TemplateId: &templateIdCreateClusterReqV2,
    		MrsEcsDefaultAgency: &mrsEcsDefaultAgencyCreateClusterReqV2,
    		NodeRootPassword: &nodeRootPasswordCreateClusterReqV2,
    		LoginMode: "PASSWORD",
    		ManagerAdminPassword: "your password",
    		SafeMode: "KERBEROS",
    		AvailabilityZone: "",
    		Components: "Hadoop,Spark2x,HBase,Hive,Hue,Loader,Kafka,Storm,Flume,Flink,Oozie,Ranger,Tez",
    		SubnetName: "subnet",
    		SubnetId: &subnetIdCreateClusterReqV2,
    		VpcName: "vpc-37cd",
    		Region: "",
    		ChargeInfo: chargeInfobody,
    		ClusterType: "CUSTOM",
    		ClusterName: "mrs_jdRU_dm02",
    		ClusterVersion: "MRS 3.1.0",
    	}
    	response, err := client.CreateCluster(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

Example response for a successful request

Error Codes

See Error Codes.