

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# クラスターの作成時のアプリケーションの設定
<a name="emr-configure-apps-create-cluster"></a>

クラスターを作成するときは、Amazon EMR コンソール、 AWS Command Line Interface (AWS CLI)、または AWS SDK を使用して、アプリケーションのデフォルト設定を上書きできます。

アプリケーションのデフォルト設定をオーバーライドするには、設定分類でカスタム値を指定します。設定分類は、アプリケーションを設定する XML ファイル (`hive-site.xml` など) に対応しています。

設定分類は、Amazon EMR のリリースバージョンによって異なります。特定のリリースバージョンで利用可能な設定分類のリストについては、「[Amazon EMR リリース 6.4.0](emr-640-release.md#emr-640-class)」などのリリース詳細ページを参照してください。

## クラスター作成時にコンソールで設定を指定する
<a name="emr-configure-apps-create-cluster-console"></a>

設定を指定するには、**[クラスターの作成]** ページに移動して **[ソフトウェア設定]** を展開します。コンソールで JSON またはシャドウテキストに倣った短縮構文を使用して、設定を直接入力できます。それ以外の方法として、JSON の `Configurations` オブジェクトとしてファイルの Amazon S3 URI を指定することもできます。

インスタンスグループの設定を指定するには、クラスターのリストでクラスターを選択し、**[設定]** タブを選択します。**[インスタンスグループの設定]** テーブルで、編集するインスタンスグループを選択し、**[再設定]** を選択します。

## クラスターの作成 AWS CLI 時に を使用して設定を指定する
<a name="emr-configure-apps-create-cluster-cli"></a>

ローカルまたは Amazon S3 に保存された JSON ファイルのパスを指定することで、**create-cluster** に対して設定を指定できます。次の例は、Amazon EMR にデフォルトのロールを使用していて、そのロールが作成されていることを前提としています。ロールを作成する必要がある場合は、最初に `aws emr create-default-roles` を実行します。

設定がローカルディレクトリにある場合は、次のコマンド例を使用できます。

```
aws emr create-cluster --use-default-roles --release-label emr-7.12.0 --applications Name=Hive \
--instance-type m5.xlarge --instance-count 3 --configurations file://./configurations.json
```

設定が Amazon S3 パスに含まれている場合は、次の次善策を設定した後に、Amazon S3 `create-cluster` パスをコマンドに渡す必要があります。

```
#!/bin/sh
# Assume the ConfigurationS3Path is not public, and its present in the same AWS account as the EMR cluster
ConfigurationS3Path="s3://amzn-s3-demo-bucket/config.json"
# Get a presigned HTTP URL for the s3Path
ConfigurationURL=`aws s3 presign $ConfigurationS3Path --expires-in 300`
# Fetch the presigned URL, and minify the JSON so that it spans only a single line
Configurations=`curl $ConfigurationURL | jq -c .`
aws emr create-cluster --use-default-roles --release-label emr-5.34.0 --instance-type m5.xlarge --instance-count 2 --applications Name=Hadoop Name=Spark --configurations $Configurations
```

## クラスター作成時に Java SDK を使用して設定を指定する
<a name="emr-configure-apps-create-cluster-sdk"></a>

 AWS SDK for Javaを使用して設定を指定する方法を次のプログラム抜粋に示します。

```
Application hive = new Application().withName("Hive");

Map<String,String> hiveProperties = new HashMap<String,String>();
	hiveProperties.put("hive.join.emit.interval","1000");
	hiveProperties.put("hive.merge.mapfiles","true");
	    
Configuration myHiveConfig = new Configuration()
	.withClassification("hive-site")
	.withProperties(hiveProperties);

RunJobFlowRequest request = new RunJobFlowRequest()
	.withName("Create cluster with ReleaseLabel")
	.withReleaseLabel("emr-5.20.0")
	.withApplications(hive)
	.withConfigurations(myHiveConfig)
	.withServiceRole("EMR_DefaultRole")
	.withJobFlowRole("EMR_EC2_DefaultRole")
	.withInstances(new JobFlowInstancesConfig()
		.withEc2KeyName("myEc2Key")
		.withInstanceCount(3)
		.withKeepJobFlowAliveWhenNoSteps(true)
		.withMasterInstanceType("m4.large")
		.withSlaveInstanceType("m4.large")
	);
```