下载 hadoop-common-bin 中含有 winutils.exe :
http://download.csdn.net/download/knight_black_bob/9722051
hdfs 本地 (win) 报没有找到 winutils.exe
严重: Failed to locate the winutils binary in the hadoop binary path java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:278) at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300) at org.apache.hadoop.util.Shell.<clinit>(Shell.java:293) at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:76) at org.apache.hadoop.conf.Configuration.getTrimmedStrings(Configuration.java:1546) at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:519) at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:453) at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:136) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2433) at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:88) at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2467) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2449) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:367) at com.curiousby.baoyou.cn.hadoop.HDFSUtils.init(HDFSUtils.java:65) at com.curiousby.baoyou.cn.hadoop.HDFSUtils.main(HDFSUtils.java:330)
hadoop 源码中 ,本地 hadoop 中没有 给出改 winutils.exe
public static final String getQualifiedBinPath(String executable) throws IOException { // construct hadoop bin path to the specified executable String fullExeName = HADOOP_HOME_DIR + File.separator + "bin" + File.separator + executable; File exeFile = new File(fullExeName); if (!exeFile.exists()) { throw new IOException("Could not locate executable " + fullExeName + " in the Hadoop binaries."); } return exeFile.getCanonicalPath(); } private static String HADOOP_HOME_DIR = checkHadoopHome(); private static String checkHadoopHome() { // first check the Dflag hadoop.home.dir with JVM scope String home = System.getProperty("hadoop.home.dir"); // fall back to the system/user-global env variable if (home == null) { home = System.getenv("HADOOP_HOME"); } ... }
解决方法:
1.首先,下载一个 hadoop.tar.gz 解压后 ,设置 环境变量 :HADOOP_HOME I:\software\hadoop-2.6.0\
2.下载 hadoop-common-2.2.0-bin ,因为 hadoop中也没有,该winutils.exe 文件,下载后,解压,将该文件复制到hadoop/bin下
下载地址: http://download.csdn.net/download/knight_black_bob/9722051
3.代码部分 文件前添加 System.setProperty("hadoop.home.dir", "I:\\software\\hadoop-2.6.0");
4.测试 ok
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!