After you create a cluster, especially a subscription cluster, you can run scripts on multiple nodes at the same time to meet your business requirements, such as to install third-party software or modify the running environment of the cluster.

Background information

You can take bootstrap actions to initialize on-demand clusters. A cluster script is similar to a bootstrap action. After a cluster is created, you can use the cluster script feature to install software and services previously unavailable to your cluster. Example:
  • Use YUM to install software already provided.
  • Download public software from the Internet.
  • Install software to read your data from Object Storage Service (OSS).
  • Install and run a service, such as Flink or Impala. However, the script you want to write is more complex.


  • A cluster is created. For more information, see Create a cluster.
  • The cluster is in the Idle or Running state. Scripts cannot run on clusters in other states.
  • Cluster scripts are developed or obtained and uploaded to OSS. For more information about the cluster scripts, see Examples.


  • Only one cluster script can run on a cluster at a specific point in time. You cannot submit another cluster script if one is already in progress. You can retain a maximum of 10 cluster script records for each cluster. If more than 10 records exist, you must delete the previous records before you create new cluster scripts.
  • A cluster script may succeed on some nodes, but fail on others. For example, if you restart a node, the script may fail to run. After you resolve the issue, you can run the cluster script on the failed nodes again. After you scale out a cluster, you can also run cluster scripts on the added nodes.

Create a cluster script

  1. Go to the Cluster Overview page.
    1. Log on to the Alibaba Cloud EMR console.
    2. In the top navigation bar, select the region where your cluster resides and select a resource group based on your business requirements.
    3. Click the Cluster Management tab.
    4. On the Cluster Management page, find your cluster and click Details in the Actions column.
  2. In the left-side navigation pane of the page that appears, click Cluster Scripts.
  3. On the Cluster Scripts page, click Create and Run in the upper-right corner.
  4. In the Create Script dialog box, specify Name, Script, and Target Nodes.
    Note We recommend that you test the cluster script feature on a single node before you use the feature on the entire cluster.
  5. Click OK.
    After a cluster script is created, it is displayed in the cluster script list and is in the Running state.
    • Click Refresh in the upper-right corner to update the status of the cluster script.
    • Click Details in the Actions column to view the running status of the cluster script.
    • Click Delete in the Actions column to delete the cluster script that you created.


Similar to a bootstrap action, you can specify the file that you want to download from OSS in the script. In the following example, the myfile.tar.gz file in the oss://yourbucket directory is downloaded to your computer and decompressed to the /yourdir directory.
osscmd --id=<yourAccessKeyId> --key=<yourAccessKeySecret> get oss://<yourBucketName>/<yourFile>.tar.gz ./<yourFile>.tar.gz
mkdir -p /<yourDir>
tar -zxvf <yourFile>.tar.gz -C /<yourDir>
Note The specified OSS address can be an internal, public, or VPC endpoint. If the node is of the classic network type, you must specify an internal endpoint. For example, the internal endpoint for a node that resides in the China (Hangzhou) region is If the node is of the VPC type, you must specify a domain name that you can access from the VPC. For example, the domain name for a node that resides in the China (Hangzhou) region is
You can also use YUM to install additional system software packages, such as
yum install -y

By default, the root account is used to run specified scripts on a cluster. You can run the su hadoop command in the script to switch to the hadoop user.