---
title: "Eclipse调用hadoop2运行MR程序"
author: "wbj0110"
date: "2014-06-25T15:52:20Z"
tags: ["Hadoop", "mahout"]
categories: ["编程语言"]
slug: "eclipse-hadoop2-mr"
draft: false
lastmod: "2014-06-25T15:52:17Z"
id: 2079496
url: "https://soledede.iteye.com/blog/2079496"
---

hadoop：hadoop2.2 ，windows myeclipse环境；

Eclipse调用hadoop运行MR程序其实就是普通的java程序可以提交MR任务到集群执行而已。在Hadoop1中，只需指定jt（jobtracker）和fs（namenode）即可，一般如下：

 

**\[java]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

1. Configuration conf = new Configuration();
2. conf.set("mapred.job.tracker", "192.168.128.138:9001");
3. conf.set("fs.default.name","192.168.128.138:9000");

上面的代码在hadoop1中运行是ok的，完全可以使用java提交任务到集群运行。但是，hadoop2却是没有了jt，新增了yarn。这个要如何使用呢？最简单的想法，同样指定其配置，试试。

 

 

**\[java]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

1. Configuration conf = new YarnConfiguration();
2. conf.set("fs.defaultFS", "hdfs://node31:9000");
3. conf.set("mapreduce.framework.name", "yarn");
4. conf.set("yarn.resourcemanager.address", "node31:8032");

恩，这样配置后，可以运行，首先是下面的错误：

 

 

**\[html]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

01. 2014-04-03 21:20:21,568 ERROR \[main] util.Shell (Shell.java:getWinUtilsPath(303)) - Failed to locate the winutils binary in the hadoop binary path
02. java.io.IOException: Could not locate executable null\\bin\\winutils.exe in the Hadoop binaries.
03. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:278)
04. at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300)
05. at org.apache.hadoop.util.Shell.&lt;clinit&gt;(Shell.java:293)
06. at org.apache.hadoop.util.StringUtils.&lt;clinit&gt;(StringUtils.java:76)
07. at org.apache.hadoop.yarn.conf.YarnConfiguration.&lt;clinit&gt;(YarnConfiguration.java:345)
08. at org.fansy.hadoop.mr.WordCount.getConf(WordCount.java:104)
09. at org.fansy.hadoop.mr.WordCount.runJob(WordCount.java:84)
10. at org.fansy.hadoop.mr.WordCount.main(WordCount.java:47)

这个错误不用管，这个好像是windows调用的时候就会出的错误。

 

然后是什么权限问题之类的，这个时候就需要去调整下权限，至少我目前是这样做的。调整的权限主要有/tmp 以及运行wordcount的输入、输出目录。命令如下： $HADOOP\_HOME/bin/hadoop fs -chmod -R 777 /tmp 。

然后直到你出现了下面的错误，那么，好了，可以说你已经成功了一半了。

 

**\[java]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

01. 2014-04-03 20:32:36,596 ERROR \[main] security.UserGroupInformation (UserGroupInformation.java:doAs(1494)) - PriviledgedActionException as:Administrator (auth:SIMPLE) cause:java.io.IOException: Failed to run job : Application application\_1396459813671\_0001 failed 2 times due to AM Container for appattempt\_1396459813671\_0001\_000002 exited with  exitCode: 1 due to: Exception from container-launch:
02. org.apache.hadoop.util.Shell$ExitCodeException: /bin/bash: line 0: fg: no job control
03. at org.apache.hadoop.util.Shell.runCommand(Shell.java:464)
04. at org.apache.hadoop.util.Shell.run(Shell.java:379)
05. at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:589)
06. at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:195)
07. at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:283)
08. at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:79)
09. at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
10. at java.util.concurrent.FutureTask.run(FutureTask.java:166)
11. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
12. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
13. at java.lang.Thread.run(Thread.java:724)
14. .Failing this attempt.. Failing the application.

用上面出现的错误去google，可以得到这个网页：https://issues.apache.org/jira/browse/MAPREDUCE-5655 。 恩，对的。这个网页就是我们的solution。

 

我们分为1、2、3步骤吧。

1\. 修改MRapps.java 、YARNRunner.java的源码，然后打包替换原来的jar包中的相应class文件，这两个jar我已经打包，可以在这里下载http://download.csdn.net/detail/fansy1990/7143547 。然后替换集群中相应的jar吧，同时需要注意替换Myeclipse中导入的包。额，说起Myeclipse中的jar包，这里还是先上幅jar包的图吧：

![](http://img.blog.csdn.net/20140403214429125?watermark%2F2%2Ftext%2FaHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmFuc3kxOTkw%2Ffont%2F5a6L5L2T%2Ffontsize%2F400%2Ffill%2FI0JBQkFCMA=%3D%2Fdissolve%2F70%2Fgravity%2FSouthEast)  
![](http://img.blog.csdn.net/20140403214451093?watermark%2F2%2Ftext%2FaHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmFuc3kxOTkw%2Ffont%2F5a6L5L2T%2Ffontsize%2F400%2Ffill%2FI0JBQkFCMA=%3D%2Fdissolve%2F70%2Fgravity%2FSouthEast)  
2\. 修改mapred-default.xml ,添加：（这个只需在eclipse中导入的jar包修改即可，修改后的jar包不用上传到集群）

 

**\[html]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

1. &lt;property&gt;
2. &lt;name&gt;mapred.remote.os&lt;/name&gt;
3. &lt;value&gt;Linux&lt;/value&gt;
4. &lt;description&gt;
5. Remote MapReduce framework's OS, can be either Linux or Windows
6. &lt;/description&gt;
7. &lt;/property&gt;

（题外话，添加了这个属性后，按说我new一个Configuration后，我使用conf.get("mapred.remote.os")的时候应该是可以得到Linux的，但是我得到的却是null，这个就不清楚是怎么了。）

 

其文件在：

![](http://img.blog.csdn.net/20140403214841125?watermark%2F2%2Ftext%2FaHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmFuc3kxOTkw%2Ffont%2F5a6L5L2T%2Ffontsize%2F400%2Ffill%2FI0JBQkFCMA=%3D%2Fdissolve%2F70%2Fgravity%2FSouthEast)  
这时，你再运行程序，额好吧程序基本可以提交了，但是还是报错，查看log，可以看到下面的错误：

 

**\[html]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

1. Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster

额，说了这么久，还是把我的wordcount程序贴出来吧：

 

 

**\[java]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

01. package org.fansy.hadoop.mr;
02. import java.io.IOException;
03. import org.apache.hadoop.conf.Configuration;
04. import org.apache.hadoop.fs.FileSystem;
05. import org.apache.hadoop.fs.LocatedFileStatus;
06. import org.apache.hadoop.fs.Path;
07. import org.apache.hadoop.fs.RemoteIterator;
08. import org.apache.hadoop.io.LongWritable;
09. import org.apache.hadoop.io.Text;
10. import org.apache.hadoop.mapred.ClusterStatus;
11. import org.apache.hadoop.mapred.JobClient;
12. import org.apache.hadoop.mapreduce.Job;
13. import org.apache.hadoop.mapreduce.Mapper;
14. import org.apache.hadoop.mapreduce.Reducer;
15. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
16. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
17. import org.apache.hadoop.yarn.conf.YarnConfiguration;
18. import org.slf4j.Logger;
19. import org.slf4j.LoggerFactory;
20. public class WordCount {
21. private static Logger log = LoggerFactory.getLogger(WordCount.class);
22. public static class WCMapper extends  Mapper&lt;LongWritable, Text, LongWritable, Text&gt; {
23. public void map(LongWritable key, Text value, Context cxt) throws IOException,InterruptedException {
24. // String\[] values= value.toString().split("\[,| ]");
25. cxt.write(key, value);
26. }
27. }
28. public static class WCReducer extends  Reducer&lt;LongWritable, Text, LongWritable,Text&gt; {
29. public void reduce(LongWritable key, Iterable&lt;Text&gt; values, Context cxt) throws IOException,InterruptedException {
30. StringBuffer buff = new StringBuffer();
31. for (Text v:values) {
32. buff.append(v.toString()+"\\t");
33. }
34. cxt.write(key, new Text(buff.toString()));
35. }
36. }
37. public static void main(String\[] args) throws Exception {
38. //    checkFS();
39. String input ="hdfs://node31:9000/input/test.dat";
40. String output="hdfs://node31:9000/output/wc003";
41. runJob(input,output);
42. //  runJob(args\[0],args\[1]);
43. //  upload();
44. }
45. /\**
46. * test operate the hdfs
47. * @throws IOException
48. \*/
49. public static void checkFS() throws IOException{
50. Configuration conf=getConf();
51. Path f= new Path("/user");
52. FileSystem fs = FileSystem.get(f.toUri(),conf);
53. RemoteIterator&lt;LocatedFileStatus&gt; paths=fs.listFiles(f, true);
54. while(paths.hasNext()){
55. System.out.println(paths.next());
56. }
57. }
58. public static void upload() throws IOException{
59. Configuration conf = getConf();
60. Path f= new Path("d:\\\\wordcount.jar");
61. FileSystem fs = FileSystem.get(f.toUri(),conf);
62. fs.copyFromLocalFile(true, f, new Path("/input/wordcount.jar"));
63. System.out.println("done ...");
64. }
65. /\**
66. *  test the job submit
67. * @throws IOException
68. * @throws InterruptedException
69. * @throws ClassNotFoundException
70. \*/
71. public static void runJob(String input,String output) throws IOException, ClassNotFoundException, InterruptedException{
72. Configuration conf=getConf();
73. Job job = new Job(conf,"word count");
74. //    job.setJar("hdfs://node31:9000/input/wordcount.jar");
75. job.setJobName("wordcount");
76. job.setJarByClass(WordCount.class);
77. //  job.setOutputFormatClass(SequenceFileOutputFormat.class);
78. job.setOutputKeyClass(LongWritable.class);
79. job.setOutputValueClass(Text.class);
80. job.setMapperClass(WCMapper.class);
81. job.setCombinerClass(WCReducer.class);
82. job.setReducerClass(WCReducer.class);
83. FileInputFormat.addInputPath(job, new Path(input));
84. //  SequenceFileOutputFormat.setOutputPath(job, new Path(args\[1]));
85. FileOutputFormat.setOutputPath(job, new Path(output));
86. System.exit(job.waitForCompletion(true)?0:1);
87. }
88. private static Configuration getConf() throws IOException{
89. Configuration conf = new YarnConfiguration();
90. conf.set("fs.defaultFS", "hdfs://node31:9000");
91. conf.set("mapreduce.framework.name", "yarn");
92. conf.set("yarn.resourcemanager.address", "node31:8032");
93. //    conf.set("mapred.remote.os", "Linux");
94. System.out.println(conf.get("mapred.remote.os"));
95. //    JobClient client = new JobClient(conf);
96. //    ClusterStatus cluster = client.getClusterStatus();
97. return conf;
98. }
99. }

3\. 如何修复上面的报错？按照那个链接的solution，需要修改mapred-default.xml 和yarn-default.xml ，其中mapred-default.xml刚才已经修改过了，这次再次修改，添加：

 

 

**\[java]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

01. &lt;property&gt;
02. &lt;name&gt;mapreduce.application.classpath&lt;/name&gt;
03. &lt;value&gt;
04. $HADOOP\_CONF\_DIR,
05. $HADOOP\_COMMON\_HOME/share/hadoop/common/\*,
06. $HADOOP\_COMMON\_HOME/share/hadoop/common/lib/\*,
07. $HADOOP\_HDFS\_HOME/share/hadoop/hdfs/\*,
08. $HADOOP\_HDFS\_HOME/share/hadoop/hdfs/lib/\*,
09. $HADOOP\_MAPRED\_HOME/share/hadoop/mapreduce/\*,
10. $HADOOP\_MAPRED\_HOME/share/hadoop/mapreduce/lib/\*,
11. $HADOOP\_YARN\_HOME/share/hadoop/yarn/\*,
12. $HADOOP\_YARN\_HOME/share/hadoop/yarn/lib/*
13. &lt;/value&gt;
14. &lt;/property&gt;

对于yarn-default.xml也是同样的修改，其在hadoop-yarn-common-2.2.0.jar包中，修改内容如下：

 

 

**\[java]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

01. &lt;property&gt;
02. &lt;name&gt;mapreduce.application.classpath&lt;/name&gt;
03. &lt;value&gt;
04. $HADOOP\_CONF\_DIR,
05. $HADOOP\_COMMON\_HOME/share/hadoop/common/\*,
06. $HADOOP\_COMMON\_HOME/share/hadoop/common/lib/\*,
07. $HADOOP\_HDFS\_HOME/share/hadoop/hdfs/\*,
08. $HADOOP\_HDFS\_HOME/share/hadoop/hdfs/lib/\*,
09. $HADOOP\_MAPRED\_HOME/share/hadoop/mapreduce/\*,
10. $HADOOP\_MAPRED\_HOME/share/hadoop/mapreduce/lib/\*,
11. $HADOOP\_YARN\_HOME/share/hadoop/yarn/\*,
12. $HADOOP\_YARN\_HOME/share/hadoop/yarn/lib/*
13. &lt;/value&gt;
14. &lt;/property&gt;

同样的，上面两个jar包只用替换myeclipse中的jar包即可，不需要替换集群中的。

 

4\. 经过上面的替换，然后再次运行，出现下面的错误：

 

**\[html]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

1. Caused by: java.lang.ClassNotFoundException: Class org.fansy.hadoop.mr.WordCount$WCMapper not found
2. at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1626)
3. at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1718)
4. ... 8 more

额，好吧，我应该不用多少了，这样的错误，应该已经说明我们的myeclipse可以提交任务到hadoop2了，并且可以运行了。好吧最后一步，上传我们打包的wordcount程序的jar文件到$HADOOP\_HOME/share/hadoop/mapreduce/lib下面，然后再次运行。（这里上传后不用重启集群）呵呵，最后得到下面的结果：

 

 

**\[html]** [view plain](http://blog.csdn.net/fansy1990/article/details/22896249 "view plain")[copy](http://blog.csdn.net/fansy1990/article/details/22896249 "copy")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/273748 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/273748/fork "派生到我的代码片")

 

01. 2014-04-03 21:17:34,289 ERROR \[main] util.Shell (Shell.java:getWinUtilsPath(303)) - Failed to locate the winutils binary in the hadoop binary path
02. java.io.IOException: Could not locate executable null\\bin\\winutils.exe in the Hadoop binaries.
03. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:278)
04. at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300)
05. at org.apache.hadoop.util.Shell.&lt;clinit&gt;(Shell.java:293)
06. at org.apache.hadoop.util.StringUtils.&lt;clinit&gt;(StringUtils.java:76)
07. at org.apache.hadoop.yarn.conf.YarnConfiguration.&lt;clinit&gt;(YarnConfiguration.java:345)
08. at org.fansy.hadoop.mr.WordCount.getConf(WordCount.java:104)
09. at org.fansy.hadoop.mr.WordCount.runJob(WordCount.java:84)
10. at org.fansy.hadoop.mr.WordCount.main(WordCount.java:47)
11. Linux
12. 2014-04-03 21:18:19,853 WARN  \[main] util.NativeCodeLoader (NativeCodeLoader.java:&lt;clinit&gt;(62)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
13. 2014-04-03 21:18:20,499 INFO  \[main] client.RMProxy (RMProxy.java:createRMProxy(56)) - Connecting to ResourceManager at node31/192.168.0.31:8032
14. 2014-04-03 21:18:20,973 WARN  \[main] mapreduce.JobSubmitter (JobSubmitter.java:copyAndConfigureFiles(149)) - Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
15. 2014-04-03 21:18:21,020 INFO  \[main] input.FileInputFormat (FileInputFormat.java:listStatus(287)) - Total input paths to process : 1
16. 2014-04-03 21:18:21,313 INFO  \[main] mapreduce.JobSubmitter (JobSubmitter.java:submitJobInternal(394)) - number of splits:1
17. 2014-04-03 21:18:21,336 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - user.name is deprecated. Instead, use mapreduce.job.user.name
18. 2014-04-03 21:18:21,337 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.jar is deprecated. Instead, use mapreduce.job.jar
19. 2014-04-03 21:18:21,337 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - fs.default.name is deprecated. Instead, use fs.defaultFS
20. 2014-04-03 21:18:21,338 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.output.value.class is deprecated. Instead, use mapreduce.job.output.value.class
21. 2014-04-03 21:18:21,338 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapreduce.combine.class is deprecated. Instead, use mapreduce.job.combine.class
22. 2014-04-03 21:18:21,339 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapreduce.map.class is deprecated. Instead, use mapreduce.job.map.class
23. 2014-04-03 21:18:21,339 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.job.name is deprecated. Instead, use mapreduce.job.name
24. 2014-04-03 21:18:21,339 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapreduce.reduce.class is deprecated. Instead, use mapreduce.job.reduce.class
25. 2014-04-03 21:18:21,340 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.input.dir is deprecated. Instead, use mapreduce.input.fileinputformat.inputdir
26. 2014-04-03 21:18:21,340 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.output.dir is deprecated. Instead, use mapreduce.output.fileoutputformat.outputdir
27. 2014-04-03 21:18:21,342 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
28. 2014-04-03 21:18:21,343 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.output.key.class is deprecated. Instead, use mapreduce.job.output.key.class
29. 2014-04-03 21:18:21,343 INFO  \[main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - mapred.working.dir is deprecated. Instead, use mapreduce.job.working.dir
30. 2014-04-03 21:18:21,513 INFO  \[main] mapreduce.JobSubmitter (JobSubmitter.java:printTokens(477)) - Submitting tokens for job: job\_1396463733942\_0003
31. 2014-04-03 21:18:21,817 INFO  \[main] impl.YarnClientImpl (YarnClientImpl.java:submitApplication(174)) - Submitted application application\_1396463733942\_0003 to ResourceManager at node31/192.168.0.31:8032
32. 2014-04-03 21:18:21,859 INFO  \[main] mapreduce.Job (Job.java:submit(1272)) - The url to track the job: http://node31:8088/proxy/application\_1396463733942\_0003/
33. 2014-04-03 21:18:21,860 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1317)) - Running job: job\_1396463733942\_0003
34. 2014-04-03 21:18:31,307 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1338)) - Job job\_1396463733942\_0003 running in uber mode : false
35. 2014-04-03 21:18:31,311 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1345)) -  map 0% reduce 0%
36. 2014-04-03 21:19:02,346 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1345)) -  map 100% reduce 0%
37. 2014-04-03 21:19:11,416 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1345)) -  map 100% reduce 100%
38. 2014-04-03 21:19:11,425 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1356)) - Job job\_1396463733942\_0003 completed successfully
39. 2014-04-03 21:19:11,552 INFO  \[main] mapreduce.Job (Job.java:monitorAndPrintJob(1363)) - Counters: 43
40. File System Counters
41. FILE: Number of bytes read=11139
42. FILE: Number of bytes written=182249
43. FILE: Number of read operations=0
44. FILE: Number of large read operations=0
45. FILE: Number of write operations=0
46. HDFS: Number of bytes read=8646
47. HDFS: Number of bytes written=10161
48. HDFS: Number of read operations=6
49. HDFS: Number of large read operations=0
50. HDFS: Number of write operations=2
51. Job Counters
52. Launched map tasks=1
53. Launched reduce tasks=1
54. Data-local map tasks=1
55. Total time spent by all maps in occupied slots (ms)=29330
56. Total time spent by all reduces in occupied slots (ms)=5825
57. Map-Reduce Framework
58. Map input records=235
59. Map output records=235
60. Map output bytes=10428
61. Map output materialized bytes=11139
62. Input split bytes=98
63. Combine input records=235
64. Combine output records=235
65. Reduce input groups=235
66. Reduce shuffle bytes=11139
67. Reduce input records=235
68. Reduce output records=235
69. Spilled Records=470
70. Shuffled Maps =1
71. Failed Shuffles=0
72. Merged Map outputs=1
73. GC time elapsed (ms)=124
74. CPU time spent (ms)=21920
75. Physical memory (bytes) snapshot=299376640
76. Virtual memory (bytes) snapshot=1671372800
77. Total committed heap usage (bytes)=152834048
78. Shuffle Errors
79. BAD\_ID=0
80. CONNECTION=0
81. IO\_ERROR=0
82. WRONG\_LENGTH=0
83. WRONG\_MAP=0
84. WRONG\_REDUCE=0
85. File Input Format Counters
86. Bytes Read=8548
87. File Output Format Counters
88. Bytes Written=10161

 

上面你看到Linux，是因为我使用了conf.set("mapred.remote.os", "Linux"); 不过在实际运行的时候却不需要设置。

另外，如果是linux系统部署的tomcat调用hadoop2集群运行MR程序的话，应该不需要替换其jar吧的，这个还有待验证。

哈，总算搞定了。这个问题也算是困扰了我好久了，期间几次想要冲破，结果都是无果而归，甚是郁闷。额，其实这个也不算是原创了，哎，国外在02/Dec/13 18:35这个时间点就搞定了。不过，我搜了好久，都没有中文的相关介绍。（如果有的话，那就是我搜索能力的问题了，居然没有搜到，哎）。

http://blog.csdn.net/fansy1990/article/details/22896249