EMR のブートストラップアクションはマスター・コア・タスクノードで実行されることを確認したメモ。
検証結果
起動時に実行するスクリプトを作成する
- s3://az-test/bootstrap.sh
#!/bin/bash set -e wget -S -T 10 -t 5 http://elasticmapreduce.s3.amazonaws.com/bootstrap-actions/file.tar.gz mkdir -p /home/hadoop/contents tar -xzf file.tar.gz -C /home/hadoop/contents
EMRクラスタを作成する
確認する
- セキュリティグループでマスターとスレーブへの SSH 接続を許可する*1。
- ssh でマスター・コア・タスクノードにログインして、/home/hadoop/contents/README が存在することを確認する。
- マスターノード
[hadoop@ip-172-31-14-243 ~]$ find . -name README -ls 524311 4 -rw-r--r-- 1 hadoop hadoop 15 Oct 22 2009 ./contents/README
-
- コアノード
[hadoop@ip-172-31-12-2 ~]$ find . -name README -ls 524311 4 -rw-r--r-- 1 hadoop hadoop 15 Oct 22 2009 ./contents/README
-
- タスクノード
[hadoop@ip-172-31-5-49 ~]$ find . -name README -ls 524311 4 -rw-r--r-- 1 hadoop hadoop 15 Oct 22 2009 ./contents/README
参考
デフォルトでは、ブートストラップアクションは Hadoop ユーザーとして実行されます。ブートストラップアクションは、sudo を使用し、ルート権限で実行できます。
すべての Amazon EMR 管理インターフェイスでブートストラップアクションがサポートされています。コンソール、AWS CLI、または API から複数の bootstrap-action パラメータを指定すると、クラスターごとに最大 16 個のブートストラップアクションを指定できます。
クラスターの作成時に、Amazon EMR コンソールからオプションでブートストラップアクションを指定できます。
CLI を使用する場合、create-cluster コマンドを使用してクラスターを作成するときに --bootstrap-actions パラメータを追加して、Amazon EMR にブートストラップアクションスクリプトへの参照を渡すことができます。--bootstrap-actions パラメータのシンタックスは次のとおりです。--bootstrap-actions Path=s3://mybucket/filename",Args=[arg1,arg2]追加のソフトウェアをインストールするためのブートストラップアクションの作成 - Amazon EMR
--bootstrap-actions (list)
Specifies a list of bootstrap actions to run on each EC2 instance when a cluster is created. Bootstrap actions run on each instance immediately after Amazon EMR provisions the EC2 instance and before Amazon EMR installs specified applications.You can specify a bootstrap action as an inline JSON structure enclosed in single quotation marks, or you can use a shorthand syntax, specifying multiple bootstrap actions, each separated by a space. When using the shorthand syntax, each bootstrap action takes the following parameters, separated by commas with no trailing space. Optional parameters are shown in [square brackets].
create-cluster — AWS CLI 1.16.67 Command Reference
- Path - The path and file name of the script to run, which must be accessible to each instance in the cluster. For example, Path=s3://mybucket/myscript.sh .
- [Name] - A friendly name to help you identify the bootstrap action. For example, Name=BootstrapAction1
- [Args] - A comma-separated list of arguments to pass to the bootstrap action script. Arguments can be either a list of values (Args=arg1,arg2,arg3 ) or a list of key-value pairs, as well as optional values, enclosed in square brackets (Args=[arg1,arg2=arg2value,arg3]) .
*1:コア・タスクノードへはマスターノード経由で接続してもよい