Amazon Elastic Mapreduce
今回は、
Webコンソールでbootstrapを設定するには
まずWebコンソールを使用して設定する方法を見ていきましょう。Webコンソールからは

まずは、
- Configure Hadoop
- Configure Daemons
- Run If
- Custom Action
「Amazon S3 Location」
Configure Hadoop
名前のとおり、
io.file.buffer.size=65536
この値は、
- core-site.
xml - hdfs-site.
xml - mapred-site.
xml
Configure Daemons
これも名前のとおりデーモン
-XX:GCTimeRatio=19
ここでパラメータとして渡すものはHadoopのhadoop-env.
Run If
Hadoop関連に限らず、
- instance.
isMaster=true echo Running on master node
デフォルトで設定されている上記3つのスクリプトは、
Custom Action
自分でbootstrapのスクリプトを作成した時に選択します。
以上から、
bootstrapでサポートされているスクリプトは以下の4つです。
- Ruby
- Python
- Perl
- bash
また、
bootstrapを設定してEMRを起動すると、

Amazon Elastic MapReduce Ruby Clientでbootstrapを設定するには
次はAmazon Elastic MapReduce Ruby Clientを使ってbootstrapを設定する方法です。本連載の第3回もあわせて確認してみてください。
設定には以下のようにelastic-mapreduceコマンドを使います。
$ ./elastic-mapreduce --create \ --name exsample \ --master-instance-type m2.xlarge \ --slave-instance-type m2.xlarge \ --num-instance 20 \ --jar s3://emrjar/examplejar \ --args wordCount,s3://input/,s3://output --enable-debugging \ --log-uri s3://emr-log/ \ --bootstrap-name "Configure Hadoop" --bootstrap-action "s3n://elasticmapreduce/bootstrap-actions/configure-hadoop" --arg "--site-key-value io.file.buffer.size=65536" \
ポイントは以下の3点を指定することです。
- --bootstrap-action
- →WebコンソールでのAmazon S3 Locationを指定します。
- --arg
- →WebコンソールでのOptional Argumentsを指定します。
複数のパラメータを使用する場合は、以下のいずれかで設定します。
- --argを複数設定する
- --argsを使って
「,」 (カンマ区切り) で設定する
- --bootstrap-name
- →WebコンソールでのNameを指定します。
Java SDKでbootstrapを設定するには
最後はJava SDKでbootstrapを設定する方法です。やり方はかんたんで、
RunJobFlowRequest runJobFlowRequest =
new RunJobFlowRequest()
.withBootstrapActions(
new BootstrapActionConfig().withName("Configure Hadoop")
.withScriptBootstrapAction(
new ScriptBootstrapActionConfig()
.withPath("s3n://elasticmapreduce/bootstrap-actions/configure-hadoop")
.withArgs("--site-key-value io.file.buffer.size=65536")))
.withName("EMR Job")
.withSteps(enableDebugging, stepConfig)
.withLogUri("s3://emr-log/")
.withInstances(new JobFlowInstancesConfig()
.withEc2KeyName("cluster-key")
.withHadoopVersion("0.20")
.withInstanceCount(10)
.withKeepJobFlowAliveWhenNoSteps(true)
.withMasterInstanceType("m1.large")
.withSlaveInstanceType("m1.large")
.withPlacement(new PlacementType()
.withAvailabilityZone("us-east-1a")));
ポイントは以下の5点を指定することです。
- RunJobFlowRequest#withBootstrapActions
- →BootstrapActionConfigを設定します。
- BootstrapActionConfig#withName
- →WebコンソールでのNameを指定します。
- BootstrapActionConfig#withScriptBootstrapAction
- →ScriptBootstrapActionConfigを設定します。
- ScriptBootstrapActionConfig#withPath
- →WebコンソールでのAmazon S3 Locationを指定します。
- ScriptBootstrapActionConfig#withArgs
- →WebコンソールでのOptional Argumentsを指定します。
その他のbootstrap
実は、
download.sh
bootstrapの動きを確認するためのサンプルです。中身を確認していただけるとわかると思いますが、
memory-intensive
EMRで指定したインスタンスタイプに合わせて、
shutdown actionsで終了時にも処理できる
ここまで起動時の処理について説明してきましたが、
- /mnt/
var/ lib/ instance-controller/ public/ shutdown-actions/
終了時に処理を行いたい場合は、
なお、
以上がbootstrapの基本です。EMRはMapReduce処理を簡単に実行できますが、
次回はbootstrapとも絡みがあるパフォーマンスについて説明します。通常のHadoop同様、