Bootstrap actions are used to run a customized script before the cluster starts Hadoop. The customized script is used to install your required third-party software or change the cluster operating environment.
With bootstrap actions, you can install and perform a variety of things to your cluster that are not currently supported by clusters, such as:
- Install 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. (The script for this 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.
- Log on to the Alibaba Cloud E-MapReduce console.
- Select a region. The cluster associated with this region is listed.
- Click Create Cluster to enter the cluster creation page.
- At the bottom of the basic configuration page, click Add to enter the operation page.
- Enter the configuration items.
You can add up to 16 bootstrap actions to be performed during cluster initialization in a specified sequence. By default, your customized script is run with the root account. Use su hadoop in the script to switch to a Hadoop account.
It is possible for a bootstrap action to fail, but this does not affect the creation of a cluster. After a cluster is created successfully, you can view all abnormalities in the bootstrap/software configuration column in the cluster details page. In the event of an abnormality, you can log on to all nodes to view the operation logs in the /var/log/bootstrap-actions directory.
Bootstrap action type
Bootstrap actions are categorized into customized bootstrap actions and operating-condition bootstrap action. The main difference is that the operating-condition bootstrap action can only operate your operation in nodes that meet the requirements.
Customized bootstrap action
For customized bootstrap actions, the position of the bootstrap action name and the execution script in OSS must be specified and, where necessary, optional parameters filled in. During cluster initialization, all nodes download the specified OSS scripts and runs them directly or after adding the optional parameters.
#! #!/bin/bash osscmd --id=<yourid> --key=<yourkey> --host=oss-cn-hangzhou-internal.aliyuncs.com get oss://<yourbucket>/<myfile>.tar.gz ./<myfile>.tar.gz mkdir -p /<yourdir> tar -zxvf <myfile>.tar.gz -C /<yourdir>
The osscmd is preinstalled on the node and can be invoked directly to download the file.
#! #!/bin/bash yum install -y ld-linux.so. 2
Operating-condition bootstrap action
instance.isMaster=true mkdir -p /tmp/abc
If you need to specify multiple operating commands, you can divide them by using a semicolon (;). For example:
instance.isMaster=true mkdir -p /tmp/abc;mkdir -p /tmp/def.