A gateway is primarily used to submit jobs to a compute cluster and provide security isolation. To simplify the deployment of a gateway environment, E-MapReduce provides a tool named EMR-CLI. This tool uses Alibaba Cloud Elastic Compute Service (ECS) to create an instance and deploy the gateway environment. If you have a DataLake, Dataflow, or OLAP cluster, refer to this topic to deploy a gateway environment.
Gateway deployment options
A Gateway is an isolation layer for job submission provided by EMR. Its core benefits include:
-
Decouple client workloads from core cluster services
Offloads client operations such as
spark-submit,hive -f, andyarn applicationfrom the master nodes. -
Enable isolation in a multi-tenant environment
Supports separate runtime environments for users or departments.
-
Improve cluster stability and maintainability
Prevents frequent job submissions, script debugging, environment conflicts, or resource contention from affecting critical services like YARN ResourceManager and HDFS NameNode.
EMR offers three Gateway options to suit different cluster types, versions, and architectural requirements.
|
Option |
Supported cluster types and versions |
Deployment and key features |
Use cases and recommendations |
|
Gateway node group |
Supports only the following clusters:
|
• Add a new node group to an existing cluster. For more information, see Manage node groups. |
Highly recommended: Use this option to quickly add a secure, isolated submission entry point to an existing DataLake or DataFlow cluster. It offers the lowest maintenance cost and ensures high configuration consistency. |
|
Gateway environment |
Supports DataLake, DataFlow, Custom, and OLAP clusters. |
• Manually deploy on an ECS instance. For details, see Use the EMR CLI to customize a Gateway environment deployment. |
A standard alternative when your cluster does not support a Gateway node group. |
|
Gateway cluster |
Supports only Hadoop and Kafka clusters. |
|
Suitable for Hadoop and Kafka clusters. |
Prerequisites
An E-MapReduce compute cluster for DataLake, Dataflow, OLAP, or Custom scenarios must be running. For instructions on creating a cluster, see Create a cluster.
Limitations
-
Cluster type: This solution applies only to deploying a gateway environment for DataLake, Dataflow, OLAP, and Custom clusters. If the cluster type and version are compatible, using a gateway node group is recommended.
For information about deploying a gateway environment for existing Hadoop and Kafka clusters, see Create a gateway cluster.
NoteOnly Alibaba Cloud accounts that created Hadoop or Kafka clusters before 17:00 (UTC+8) on December 19, 2022, can continue to create them.
-
Overwrite installation: EMR-CLI deploys gateway clients in overwrite mode. Redeploying on an ECS instance with an existing gateway overwrites the old client and installs the new client in the same directory.
-
Isolated deployment: Do not use an existing ECS instance from your EMR cluster (such as a Master, Core, or Task node) as the gateway node. This prevents the client environment from interfering with normal cluster operations.
-
Supported services: This deployment method supports clients for the following services: HDFS, YARN, HBase, Hive, Spark 2, Spark 3, JindoSDK, Flink, Sqoop, Impala, Presto, Hudi, Iceberg, Tez, and Delta Lake.
First-time deployment
-
On the ECS console, create an instance. For more information, see Create an instance by using the wizard.
NoteThe ECS instance does not require public network access.
The following parameter settings are recommended.
Parameter
Description
Region and zone
Same region and zone as the EMR cluster.
Image
Same operating system as the EMR cluster's instances.
System disk
An ESSD of at least 60 GiB is recommended.
Network
Same Virtual Private Cloud (VPC) as the EMR cluster.
Security group
Use the same security group as the EMR cluster's master node group. This ensures network connectivity between the ECS instance and the EMR cluster.
-
Create a dedicated ECS RAM role for the EMR gateway.
-
Log on to the RAM console as a RAM administrator.
-
In the left-side navigation pane, choose .
-
On the Role page, click Create Role.
-
In the Create Role panel, set Principal Type to Cloud Service and Principal Name to Elastic Compute Service, and then click OK.
-
Enter a Role Name (for example, ECSForEMRGatewayRole), and then click OK.
-
-
Grant permissions to the RAM role.
-
On the Permission Settings tab, click Add Authorization.
-
In the Add Authorization panel, select System Policy. Search for and select AliyunEMRFullAccess, AliyunOSSFullAccess, and AliyunDLFFullAccess. Then, click OK.
-
Click Close.
-
-
Attach the RAM role to the ECS instance.
Log in to the ECS console.
-
In the left navigation bar, select .
-
In the top menu bar, select the region.
-
Find the newly created ECS instance and choose .
-
In the dialog box that appears, select the ECSForEMRGatewayRole role and click OK.
-
Connect to the ECS instance. For more information, see Connect to an instance.
-
Run the following command to install EMR-CLI.
regionId=`curl http://100.100.100.200/latest/meta-data/region-id`; curl https://ecm-repo-${regionId}.oss-${regionId}-internal.aliyuncs.com/emrcli/emrcli.sh -o /tmp/emrcli.sh; chmod 755 /tmp/emrcli.sh; sh /tmp/emrcli.sh install ${regionId}A successful installation returns the following message:
install emrcli success -
Run the following command to deploy the EMR gateway client.
emrcli gateway deploy \ --clusterId <ClusterId> \ --appNames <ApplicationName>Replace the following parameters with your actual values.
Parameter
Required
Description
clusterId
Yes
The ID of your E-MapReduce cluster.
appNames
No
The application names. To specify multiple applications, separate the names with a comma (,), for example,
HDFS,YARN.If this parameter is omitted, clients for all supported applications in the cluster, such as Hive and HDFS, are installed by default.
A successful deployment returns the following message:
deployGateway successImportantAfter the gateway is installed, the
JAVA_HOMEsystem environment variable is set to/usr/lib/jvm/java-1.8.0. You can modify it in the /etc/profile.d/emr_env.sh file, but this may affect gateway functionality. Proceed with caution. -
Log in to the ECS instance again to apply the new environment variables.
-
Optional: Configure DNS resolution for the gateway node.
ImportantThis step is required if the gateway includes the Spark service.
-
Add a zone. For more information, see Add a built-in authoritative zone.
-
Add a DNS record. For more information, see Add DNS records.
The following table describes the required parameters.
Parameter
Description
Record type
Use the default value A.
Hostname
Enter the hostname of the gateway node, for example, iZ2zea8r0aht2vzbqci****.
You can obtain the hostname by running the
hostnamecommand.Record value
Enter the internal IP address of the gateway node.
You can view this address on the node management page.
TTL value
Use the default value.
-
Gateway management
After creating the gateway, if you add new services to the associated cluster or change service configurations, you can run commands to update client components or synchronize the latest configurations.
Update client components
If a new service, such as Flink, is added to the EMR cluster, you can incrementally install the corresponding client on the gateway node. The deploy command overwrites the configurations of existing applications and incrementally installs new ones.
# Example: Add the FLINK client to an existing HDFS and YARN setup
emrcli gateway deploy \
--clusterId <ClusterId> \
--appNames HDFS,YARN,FLINK
A successful update returns the following message:
deployGateway success
Synchronize configurations
If you change a service configuration in the EMR cluster (for example, you modify core-site.xml on the E-MapReduce console), you must manually synchronize the new configuration to the gateway node.
Synchronizing configurations overwrites the existing configurations on the gateway. Proceed with caution.
# Run the synchronization command
emrcli gateway refreshConfigs \
--clusterId <ClusterId> \
--appNames <ApplicationName> # Optional. Specify the applications to synchronize.
A successful synchronization returns the following message:
refreshConfiguration success
EMR-CLI management
View EMR-CLI version
Run the following command to view the EMR-CLI version.
emrcli version
The command returns information similar to the following:
2.0.0
Upgrade EMR-CLI
To upgrade to the latest version, rerun the EMR-CLI installation step in Deploy a gateway environment for the first time.
FAQ
Q: How do I switch compute clusters?
A: To switch compute clusters, follow these steps:
-
To prevent data loss, use the
mvcommand to manually back up files from the old cluster. Back up the/opt/appsdirectory, the/etc/taihao-appsdirectory, and the/etc/profile.d/yarn.shfile. -
Follow the steps in this topic to redeploy the gateway environment for the new cluster.
> Instance Settings > Attach/Detach RAM Role