在用e-mapreduce平台的时,为了性能或者其它的目的,我需要修改一些mapreduce的参数,比如:map的个数,mapreduce.map.java.opts、mapreduce.map.memory.mb等。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
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);
}