开发者社区 问答 正文

mapreduce怎么修改一些参数

已解决

在用e-mapreduce平台的时,为了性能或者其它的目的,我需要修改一些mapreduce的参数,比如:map的个数,mapreduce.map.java.opts、mapreduce.map.memory.mb等。

展开
收起
封神 2016-06-01 10:40:41 2742 分享 版权
1 条回答
写回答
取消 提交回答
  • 专注在大数据分布式计算、数据库及存储领域,拥有13+年大数据引擎、数据仓库、宽表引擎、平台研发经验,6年云智能大数据产品技术一号位经验,10年技术团队管理经验;云智能技术架构/云布道师; 研发阿里历代的大数据技术产品包括ODPS、DLA、ADB,最近五年主导宽表引擎研发、DLA、ADB湖仓研发;
    采纳回答

    1、参数分为客户参数与服务端参数,客户端的参数都可以改的,服务端的参数一般需要运维同学修改(emapreduce后续可能会提供修改参数的服务,一些参数可能需要重启集群)
    2、客户端的参数,我们不建议去修改默认的配置文件。建议在执行命令的时候,按照 -Dx=y去修改

     bin/hadoop jar wc.jar WordCount2 -Dwordcount.case.sensitive=true /user/joe/wordcount/input /user/joe/wordcount/output -skip /user/joe/wordcount/patterns.txt

    在写代码的时候,特别要注意,可以参考hadoop的例子 wordcount

    从整个流程看,-Dx=y是在客户端放到configuration的xml的文件中。

    需要让-D有效果,则写代码的时候加上 :

        String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

    wordcount的main函数见:

      public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
        if (otherArgs.length < 2) {
          System.err.println("Usage: wordcount <in> [<in>...] <out>");
          System.exit(2);
        }
        Job job = Job.getInstance(conf, "word count");
        job.setJarByClass(WordCount.class);
        job.setMapperClass(TokenizerMapper.class);
        job.setCombinerClass(IntSumReducer.class);
        job.setReducerClass(IntSumReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);
        for (int i = 0; i < otherArgs.length - 1; ++i) {
          FileInputFormat.addInputPath(job, new Path(otherArgs[i]));
        }
        FileOutputFormat.setOutputPath(job,
          new Path(otherArgs[otherArgs.length - 1]));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
      }
    
    2019-07-17 19:22:52
    赞同 1 展开评论