java - 创建集群需要 InstanceProfile

标签 java amazon-web-services hadoop amazon-iam amazon-emr

我试图从 Eclipse 运行 Elastic MapReduce,但无法这样做。

我的代码如下:

public class RunEMR {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         AWSCredentials credentials = new BasicAWSCredentials("xxxx","xxxx");
            AmazonElasticMapReduceClient emr = new AmazonElasticMapReduceClient(credentials);

            StepFactory stepFactory = new StepFactory();

            StepConfig enableDebugging = new StepConfig()
                .withName("Enable Debugging")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newEnableDebuggingStep());

            StepConfig installHive = new StepConfig()
                .withName("Install Hive")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newInstallHiveStep());

            StepConfig hiveScript = new StepConfig().withName("Hive Script")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newRunHiveScriptStep("s3://mywordcountbuckett/binary/WordCount.jar"));

            RunJobFlowRequest request = new RunJobFlowRequest()
                .withName("Hive Interactive")
                .withSteps(enableDebugging, installHive)
                .withLogUri("s3://mywordcountbuckett/")
                .withInstances(new JobFlowInstancesConfig()
                    .withEc2KeyName("xxxx")
                    .withHadoopVersion("0.20")
                    .withInstanceCount(3)
                    .withKeepJobFlowAliveWhenNoSteps(true)
                    .withMasterInstanceType("m1.small")
                    .withSlaveInstanceType("m1.small"));

            RunJobFlowResult result = emr.runJobFlow(request);



    }

}

我得到的错误是:

Exception in thread "main" com.amazonaws.AmazonServiceException: InstanceProfile is required for creating cluster. (Service: AmazonElasticMapReduce; Status Code: 400; Error Code: ValidationException; Request ID: 7a96ee32-9744-11e5-947d-65ca8f7db0a5

我已经尝试了几个小时但无法修复它。有谁知道怎么做?

最佳答案

我遇到了同样的异常InstanceProfile is required for creating cluster

必须像下面这样设置服务角色和工作流程角色

aRunJobFlowRequest.setServiceRole("EMR_DefaultRole")
aRunJobFlowRequest.setJobFlowRole("EMR_EC2_DefaultRole")

在那之后我就没事了。


AWS Document for EMR IAM Roles

AWS Identity and Access Management (IAM) roles provide a way for IAM users or AWS services to have certain specified permissions and access to resources. For example, this may allow users to access resources or other services to act on your behalf. You must specify two IAM roles for a cluster: a role for the Amazon EMR service (service role), and a role for the EC2 instances (instance profile) that Amazon EMR manages.

所以异常消息中的单词 InstanceProfile 可能意味着 a role for the EC2 instances (instance profile) 在文档中,但我在指定 后通过了该异常作业流角色。有点奇怪。

关于java - 创建集群需要 InstanceProfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33995463/

相关文章:

amazon-web-services - 如何使用awslog驱动程序从docker容器获取日志?

performance - 如何获取 spark 作业的指标?

scala - 为什么 spark-shell 因 NullPointerException 而失败?

java - 将多个索引项转换为流的最简单方法

amazon-web-services - awscli : copy only part of the file from s3 to local

java - 我可以在多个环境中使用单个 war 文件吗?我是不是该?

linux - 为什么我没有使用的技术在我的 AWS 服务器上

hadoop - Spark-任务异常

java - Guava ImmutableMap 的访问速度明显比 HashMap 慢

Java:在类实例上调用时不能从静态上下文引用非静态变量