这个官方的bug之前遇到过。。。。。。。。。。。。。。。。。。。。。可是。。。。。。。
==================================================
12/04/24 15:32:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes
where applicable
12/04/24 15:32:44 ERROR security.UserGroupInformation: PriviledgedActionException as:Administrator cause:java.io.IOException: Failed to set permissions of path:
\tmp\hadoop-Administrator\mapred\staging\Administrator-519341271\.staging to 0700
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-Administrator\mapred\staging\Administrator-519341271\.staging to 0700
==========================================================================
这个是Windows下文件权限问题,在Linux下可以正常运行,不存在这样的问题。
解决方法是,修改/hadoop-1.0.2/src/core/org/apache/hadoop/fs/FileUtil.java里面的checkReturnValue,注释掉即可(有些粗暴,在Window下,可以不用检查)
...... private static void checkReturnValue(boolean rv, File p, FsPermission permission ) throws IOException { /** if (!rv) { throw new IOException("Failed to set permissions of path: " + p + " to " + String.format("%04o", permission.toShort())); } **/ }
重新编译打包hadoop-core-1.0.2.jar,替换掉hadoop-1.0.2根目录下的hadoop-core-1.0.2.jar即可。
也可以把源码中的org.apache.hadoop.fs包一起拷贝到项目中,然后修改FileUtil.java中的checkReturnValue方法把里面的内容注释掉即可
替换之后,刷新项目,设置好正确的jar包依赖,现在再运行WordCountTest,即可。
====================================================================================
官方BUG参考:
https://issues.apache.org/jira/browse/HADOOP-7682
解决方法:
1、下载并解压http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-1.1.2/hadoop-1.1.2.tar.gz
2、修改hadoop-1.1.2\src\core\org\apache\hadoop\fs\FileUtil.java,搜索 Failed to set permissions of path,找到689行,把throw new IOException改为LOG.warn
3、修改hadoop-1.1.2\build.xml,搜索autoreconf,移除匹配的6个executable="autoreconf"的exec配置
4、下载解压ant,将ant目录下的bin目录加入环境变量path
5、在命令行切换到hadoop-1.1.2目录,执行ant
6、用新生成的hadoop-1.1.2\build\hadoop-core-1.1.3-SNAPSHOT.jar替换hadoop-core-1.0.3.jar