【问题标题】:Hadoop V2.7 and EclipseHadoop V2.7 和 Eclipse
【发布时间】:2015-07-06 02:10:51
【问题描述】:

我已经在我的 mac 中设置了 Hadoop v2.7,我能够启动 Hadoop 守护进程。

我想用 Eclipse 编写 MR 程序,我需要一些帮助来获取我的 Eclipse 上的 hadoop,我想知道要添加的 jar 文件和基本设置指南

以下是我的驱动类代码,我无法执行

public class MyJobDriver extends Configured implements Tool {



    @Override
    public int run(String[] args) throws Exception {
        Configuration conf = getConf();
        JobConf job = new JobConf(conf, MyJobDriver.class);

        Path in = new Path(args[0]);
        Path out = new Path(args[1]);
        FileInputFormat.setInputPaths(job, in);
        FileOutputFormat.setOutputPath(job, out);

        job.setJobName("Patent");

        job.setMapperClass(InverseMapper.class);
        //Input Split consist two values separated by ","
        //K1 and V1 type is Text
        job.setInputFormat(KeyValueTextInputFormat.class);  
        job.set("key.value.separator.in.input.line",",");//Everything before the separator is the key and after is the value

        job.setOutputFormat(TextOutputFormat.class);//Key and value written as string and separated by tab(default)
        //when k1 and k2 are od same type and V1 and V2 are of same type
        //we can skip job.setMapOutputKeyClass() and job.setMapOutputValueClass()
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        //jobClient communicates with the JobTrackers to start job across clusters
        JobClient.runJob(job);
        return 0;
    }
        public static void main(String[] args) throws Exception {
            MyJobDriver driver = new MyJobDriver();
            System.out.println("Calling the run method");
             int exitCode = ToolRunner.run(driver, args);
             System.exit(exitCode);
    }

【问题讨论】:

  • 您遇到的错误是什么?
  • 所有你需要在你的Build Path中包含来自/usr/lib/hadoop/client/的罐子
  • 是的,我添加了 jar 文件,但以不同的方式,我必须导航到 hadoop 文件夹并搜索 .jar 文件,我将 jar 复制到单独的目录,因为我找不到路径/usr/... 来自 Eclipse 构建路径。它现在工作正常。有没有办法在 Mac 上以简单的方式做到这一点?

标签: eclipse hadoop


【解决方案1】:

跟踪和检索必要的jar文件太麻烦了(有很多)。而是在 eclipse 中创建一个 maven 项目并添加必要的依赖项,如此处所述https://hadoopi.wordpress.com/2013/05/25/setup-maven-project-for-hadoop-in-5mn/

【讨论】:

  • 感谢山木加!到目前为止我还没有使用过maven,我会尝试这种方法
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-23
  • 1970-01-01
  • 2017-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多