我试图通过Java SDK for AWS启动一个小型EMR集群。我在法兰克福(eu-central-1)尝试并失败,但在N. Virginia(us-east-1)推出它时取得了成功。
我的配置:
我已经验证了以下内容:
M1Medium
)存在于两个地区。IAM Roles
来支持群集(默认群集 - EMR_EC2_DefaultRole
& EMR_DefaultRole
),它们显然可以正常工作,因为它们用于在N中启动群集弗吉尼亚州。这是在法兰克福推出集群的代码:
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. Virginia启动时,我只需将eu-central-1
替换为us-east-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)
答案 0 :(得分:0)
好的,找到了解决方案:我使用M3Xlarge
个实例而不是M2Medium
启动了群集。像魅力一样工作!
我是如何做到的:
Create and Use IAM Roles with the AWS CLI
下找到了示例here)。View cluster details
,然后单击顶行AWS CLI export
上的按钮。