Bootstrap action is used to run your customized script before the cluster starts up Hadoop. The customized script is used to install your required third-party software or change the cluster operating environment.

Function of bootstrap operation

With bootstrap action, you can install many things to your cluster that are not currently supported by clusters. For example:

  • Install provided software with Yum.
  • Directly download open software from a public network.
  • Read your data from OSS.
  • Install and operate a service, such as Flink or Impala, but the script to be compiled is more complex.

We strongly recommend that you test the bootstrap action with a Pay-As-You-Go cluster and create a subscription cluster only after the test is successful.

How to use

  1. Log on to the Alibaba Cloud E-MapReduce console.
  2. Select the region where the created cluster associated with the region is listed.
  3. Click Create Cluster to enter the cluster creation page.
  4. At the end of the basic configuration page, click Add to enter the operation page.
  5. Enter the configuration items.

You can add up to 16 bootstrap actions to be performed during cluster initialization in the designated sequence. By default, your designated script is run with the root account. You can switch to a Hadoop account with su hadoop in the script.

It is possible that the bootstrap action fails. For ease of use, bootstrap action failure does not affect the creation of the cluster. After the cluster is created successfully, you can view any abnormality in the Bootstrap/software configuration column of cluster information in the cluster details page. In case of any abnormality, you can log on to all nodes to view the operation logs in the directory of /var/log/bootstrap-actions.

Bootstrap action type

The bootstrap action is categorized into customized bootstrap action and operating-condition bootstrap action. The main difference is that the operating-condition bootstrap action can only operate your designated operation in the node that meets the requirements.

Customized bootstrap action

For the customized bootstrap action, the position of the bootstrap action name and the execution script in OSS must be designated and the optional parameters are set as required. During cluster initialization, all nodes download the designated OSS scripts to run them directly or after adding the optional parameters.

You can designate the files that need to be downloaded from OSS in the script. The following example downloads the file oss://yourbucket/myfile.tar.gz locally and extract it to the directory of /yourdir:
#! #!/bin/bash
osscmd --id=<yourid> --key=<yourkey> get oss://<yourbucket>/<myfile>.tar.gz ./<myfile>.tar.gz
mkdir -p /<yourdir>
tar -zxvf <myfile>.tar.gz -C /<yourdir>

The osscmd has been preinstalled on the node and can be invoked directly to download the file.

Notice OSS address host contains intranet address, Internet address, and VPC network address. For the classic network, the intranet address is designated. The address in Hangzhou is For VPC network, the domain name that VPC intranet can visit is designated. The name in Hangzhou is
The bootstrap action can install additional system software packages through Yum. The following example shows the installation of 2:
#! #!/bin/bash
yum install -y 2

Operating-condition bootstrap action

The execution script of an operating-condition bootstrap action is predefined, you do not need to make additional designations. You do need to designate the name and optional parameters. The operating-condition bootstrap action must provide the optional parameters, including the spaced operation conditions and commands. The operation conditions support instance.isMaster=true/false and is designated to only operate on the master or non-master nodes. The following example shows that the optional parameters of an operating-condition bootstrap action are only designated to create the directory on the master node.
instance.isMaster=true mkdir -p /tmp/abc

If multiple operation commands are designated, you can divide several statements with the semicolon “;”. For example: instance.isMaster=true mkdir -p /tmp/abc;mkdir -p /tmp/def.