0
我試圖通過適用於AWS的Java SDK啓動小型EMR羣集。我試圖在法蘭克福(eu-central-1)發射,但在弗吉尼亞北部(美國東部1號)發射時發射成功。未能在法蘭克福啓動AWS-EMR羣集,但在北弗吉尼亞州成功
我的配置:
- MACOS 10.12.1
- 的Java 1.8.102
- AWS SDK的Java 60年1月11日
- 的Hadoop 2.7.3
- 的IntelliJ 2016年2月4日
我已經驗證以下內容:
- 我請求的實例類型(
M1Medium
)存在於兩個區域中。 - 我正在請求羣集(2.7.3)的Hadoop版本是存在於EMR版本(5.2.0)中的版本。
- 我有適當的
IAM Roles
來支持羣集(默認的 -EMR_EC2_DefaultRole
&EMR_DefaultRole
),並且它們顯然工作正常,因爲它們用於在弗吉尼亞北部啓動羣集。 - 我有兩個區域的EC2密鑰對。
- 我已驗證EMR在兩個地區均可作爲服務提供。
- 我已經通過我的網絡瀏覽器通過EC2儀表板驗證了我正在爲兩個區域使用正確的可用區域,並且這些區域是健康的。
- 對於每個集羣嘗試,我在同一個區域使用一個S3存儲桶來輸入,輸出和EMR日誌。
這是啓動羣集在法蘭克福代碼:
public static void main(String[] args) throws Exception {
parseArgs(args);
if (environment.equals("local")) {
// Local machine, single node setup. Used in order to debug the M-R logic.
String[] p1args = {"input", "output", environment};
Phase1.main(p1args);
} else {
// EMR setup. This is the main intent of this app.
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
AmazonElasticMapReduce mapReduce = new AmazonElasticMapReduceClient(credentials);
HadoopJarStepConfig jarStep1 = new HadoopJarStepConfig()
.withJar("s3n://skill-finder-eu-central-1/jars/SkillFinder.jar")
.withMainClass("Phase1")
.withArgs("s3n://skill-finder-eu-central-1/input-10K", "s3n://skill-finder-eu-central-1/output-eu-central-1", environment);
StepConfig step1Config = new StepConfig()
.withName("Phase 1")
.withHadoopJarStep(jarStep1)
.withActionOnFailure("TERMINATE_JOB_FLOW");
JobFlowInstancesConfig instances = new JobFlowInstancesConfig()
.withInstanceCount(5)
.withMasterInstanceType(InstanceType.M1Medium.toString())
.withSlaveInstanceType(InstanceType.M1Medium.toString())
.withHadoopVersion("2.7.3")
.withEc2KeyName("AWS-EU-CENTRAL-1")
.withKeepJobFlowAliveWhenNoSteps(false)
.withPlacement(new PlacementType("eu-central-1a"));
RunJobFlowRequest runFlowRequest = new RunJobFlowRequest()
.withName("skill-finder")
.withInstances(instances)
.withSteps(step1Config)
.withJobFlowRole("EMR_EC2_DefaultRole")
.withServiceRole("EMR_DefaultRole")
.withReleaseLabel("emr-5.2.0")
.withLogUri("s3n://skill-finder-eu-central-1/logs/")
.withBootstrapActions();
System.out.println("Submitting the JobFlow Request to Amazon EMR and running it...");
RunJobFlowResult runJobFlowResult = mapReduce.runJobFlow(runFlowRequest);
String jobFlowId = runJobFlowResult.getJobFlowId();
System.out.println("Ran job flow with id: " + jobFlowId);
}
}
當N.弗吉尼亞州發射,我只是us-east-1
取代eu-central-1
。
這是例外:
Exception in thread "main" com.amazonaws.services.elasticmapreduce.model.AmazonElasticMapReduceException: Specified Availability Zone is not supported. (Service: AmazonElasticMapReduce; Status Code: 400; Error Code: ValidationException; Request ID: 578db9ad-b3bf-11e6-9a57-5179acb16d3f)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1545)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1183)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:964)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:676)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:650)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:633)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$300(AmazonHttpClient.java:601)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:583)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:447)
at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.doInvoke(AmazonElasticMapReduceClient.java:1469)
at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.invoke(AmazonElasticMapReduceClient.java:1445)
at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.runJobFlow(AmazonElasticMapReduceClient.java:1255)
at MRTaskLauncher.main(MRTaskLauncher.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
您是否在.aws/credentials中指定了一個區域? – Gonfva
不,在'[default]'下有一個訪問密鑰和祕密訪問密鑰。 – asafc
你可以測試添加'mapReduce.setEndpoint(「https://elasticmapreduce.eu-central-1.amazonaws.com」);'mapReduce實例化後? (未經測試) – Gonfva