平时一般是在windows环境下进行开发,在windows 环境下操作hbase可能会出现异常(java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.),以前也遇到过这个问题,今天又有小伙伴遇到这个问题,就顺带记一笔,异常信息如下:

  1. 2016-05-23 17:02:13,551 WARN [org.apache.hadoop.util.NativeCodeLoader] - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  2. 2016-05-23 17:02:13,611 ERROR [org.apache.hadoop.util.Shell] - Failed to locate the winutils binary in the hadoop binary path
  3. java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
  4. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:278)
  5. at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300)
  6. at org.apache.hadoop.util.Shell.<clinit>(Shell.java:293)
  7. at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:76)
  8. at org.apache.hadoop.conf.Configuration.getStrings(Configuration.java:1514)
  9. at org.apache.hadoop.hbase.zookeeper.ZKConfig.makeZKProps(ZKConfig.java:113)
  10. at org.apache.hadoop.hbase.zookeeper.ZKConfig.getZKQuorumServersString(ZKConfig.java:265)
  11. at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:159)
  12. at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:134)
  13. at org.apache.hadoop.hbase.client.ZooKeeperKeepAliveConnection.<init>(ZooKeeperKeepAliveConnection.java:43)
  14. at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getKeepAliveZooKeeperWatcher(HConnectionManager.java:1710)
  15. at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:82)
  16. at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.retrieveClusterId(HConnectionManager.java:806)
  17. at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:633)
  18. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  19. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  20. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  21. at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  22. at org.apache.hadoop.hbase.client.HConnectionManager.createConnection(HConnectionManager.java:387)
  23. at org.apache.hadoop.hbase.client.HConnectionManager.createConnection(HConnectionManager.java:282)
  24. at net.shgaoxin.db.hbase.HbaseConnectionFactory.createResource(HbaseConnectionFactory.java:67)
  25. at net.shgaoxin.db.hbase.HbaseConnectionFactory.makeObject(HbaseConnectionFactory.java:40)
  26. at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
  27. at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
  28. at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
  29. at net.shgaoxin.base.AbstractPooledContainer.get(AbstractPooledContainer.java:49)
  30. at net.shgaoxin.db.hbase.HbaseConnectionContainer.getConnection(HbaseConnectionContainer.java:46)
  31. at net.shgaoxin.db.hbase.HbaseConnectionContainer.getConnection(HbaseConnectionContainer.java:14)
  32. at net.shgaoxin.db.hbase.HbaseTemplate.scan(HbaseTemplate.java:398)
  33. at net.shgaoxin.impl.dao.hbase.GenericDaoHbaseImpl.scan(GenericDaoHbaseImpl.java:73)
  34. at net.shgaoxin.impl.service.eastdayminisitesp.ImgUploadServiceImpl.getCurrentStepRowkeys(ImgUploadServiceImpl.java:260)
  35. at net.shgaoxin.impl.context.eastdayminisitesp.AsyncImgUploadContextImpl.doOnStart(AsyncImgUploadContextImpl.java:81)
  36. at net.shgaoxin.impl.context.AbstractProcessQueue.start(AbstractProcessQueue.java:119)
  37. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  38. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  39. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  40. at java.lang.reflect.Method.invoke(Method.java:606)

查看hadoop源码:

  1. /** fully qualify the path to a binary that should be in a known hadoop
  2. * bin location. This is primarily useful for disambiguating call-outs
  3. * to executable sub-components of Hadoop to avoid clashes with other
  4. * executables that may be in the path. Caveat: this call doesn't
  5. * just format the path to the bin directory. It also checks for file
  6. * existence of the composed path. The output of this call should be
  7. * cached by callers.
  8. * */
  9. public static final String getQualifiedBinPath(String executable)
  10. throws IOException {
  11. // construct hadoop bin path to the specified executable
  12. String fullExeName = HADOOP_HOME_DIR + File.separator + "bin"
  13. + File.separator + executable;
  14.  
  15. File exeFile = new File(fullExeName);
  16. if (!exeFile.exists()) {
  17. throw new IOException("Could not locate executable " + fullExeName
  18. + " in the Hadoop binaries.");
  19. }
  20.  
  21. return exeFile.getCanonicalPath();
  22. }
  1. private static String HADOOP_HOME_DIR = checkHadoopHome();
  2.  
  3. /** Centralized logic to discover and validate the sanity of the Hadoop
  4. * home directory. Returns either NULL or a directory that exists and
  5. * was specified via either -Dhadoop.home.dir or the HADOOP_HOME ENV
  6. * variable. This does a lot of work so it should only be called
  7. * privately for initialization once per process.
  8. **/
  9. private static String checkHadoopHome() {
  10.  
  11. // first check the Dflag hadoop.home.dir with JVM scope
  12. String home = System.getProperty("hadoop.home.dir");
  13.  
  14. // fall back to the system/user-global env variable
  15. if (home == null) {
  16. home = System.getenv("HADOOP_HOME");
  17. }
  18.  
  19. try {
  20. // couldn't find either setting for hadoop's home directory
  21. if (home == null) {
  22. throw new IOException("HADOOP_HOME or hadoop.home.dir are not set.");
  23. }
  24.  
  25. if (home.startsWith("\"") && home.endsWith("\"")) {
  26. home = home.substring(1, home.length()-1);
  27. }
  28.  
  29. // check that the home setting is actually a directory that exists
  30. File homedir = new File(home);
  31. if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) {
  32. throw new IOException("Hadoop home directory " + homedir
  33. + " does not exist, is not a directory, or is not an absolute path.");
  34. }
  35.  
  36. home = homedir.getCanonicalPath();
  37.  
  38. } catch (IOException ioe) {
  39. if (LOG.isDebugEnabled()) {
  40. LOG.debug("Failed to detect a valid hadoop home directory", ioe);
  41. }
  42. home = null;
  43. }
  44.  
  45. return home;
  46. }
  1.  
  1.  

结合异常不难发现HADOOP_HOME_DIR值为null,基本上可以判断是 HADOOP_HOME环境变量的问题,实际上本来就没有配置hadoop的环境变量,报错也是理所当然了。

配置windows环境变量需要有winutils.exe,有大神提供了一个windows下环境配置所需文件,可参考https://github.com/srccodes/hadoop-common-2.2.0-bin

windows 中使用hbase 异常:java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.的更多相关文章

  1. spark开发常见问题之一:java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

    最近在学习研究pyspark机器学习算法,执行代码出现以下异常: 19/06/29 10:08:26 ERROR Shell: Failed to locate the winutils binary ...

  2. java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries

    在已经搭建好的集群环境Centos6.6+Hadoop2.7+Hbase0.98+Spark1.3.1下,在Win7系统Intellij开发工具中调试Spark读取Hbase.运行直接报错: ? 1 ...

  3. Spark- ERROR Shell: 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.

    运行 mport org.apache.log4j.{Level, Logger} import org.apache.spark.rdd.RDD import org.apache.spark.{S ...

  4. Spark报错java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

    Spark 读取 JSON 文件时运行报错 java.io.IOException: Could not locate executable null\bin\winutils.exe in the ...

  5. spark-local-运行异常-Could not locate executable null\bin\winutils.exe in the Hadoop binaries

    windows下-local模式-运行spark: 1.下载winutils的windows版本 GitHub上,有人提供了winutils的windows的版本,项目地址是:https://gith ...

  6. 安装spark 报错:java.io.IOException: Could not locate executable E:\hadoop-2.7.7\bin\winutils.exe

    打开 cmd 输入 spark-shell 虽然可以正常出现 spark 的标志符,但是报错:java.io.IOException: Could not locate executable E:\h ...

  7. hbase异常:java.io.IOException: Unable to determine ZooKeeper ensemble

    项目中用到hbase,有时候可能会报一些异常,比如java.io.IOException: Unable to determine ZooKeeper ensemble 等等,当出现这个问题时,根据个 ...

  8. Windows下运行MapReduce程序出现Could not locate executable null\winutils.exe in the Hadoop binaries.

    运行环境:windows10 64位,虚拟机:Ubuntu Kylin 14.04,Hadoop2.7.1 错误信息: java.io.IOException: Could not locate ex ...

  9. geotools导出shapefile出错: java.io.IOException: Current fid index is null, next must be called before write()

    geotools导出shapefile出错: java.io.IOException: Current fid index is null, next must be called before wr ...

随机推荐

  1. hihocoder #1394 : 网络流四·最小路径覆盖(最小路径覆盖)

    #1394 : 网络流四·最小路径覆盖 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 国庆期间正是旅游和游玩的高峰期. 小Hi和小Ho的学习小组为了研究课题,决定趁此机 ...

  2. MyEclipse - 问题集 - Workspace in use or cannot be created, choose a different one(转)

    转:http://wsfly.iteye.com/blog/1044986 eclipse 使用一段时间后,有时会因为一些故障自己就莫名奇妙的关闭了,再打开时有时没有问题,有时有会提示错误 Works ...

  3. Android学习笔记(四)之碎片化Fragment实现仿人人客户端的侧边栏

    其实一种好的UI布局,可以使用户感到更加的亲切与方便.最近非常流行的莫过于侧边栏了,其实我也做过很多侧边栏的应用,但是那些侧边栏的使用我 都不是很满意,现在重新整理,重新写了一个相对来说我比较满意的侧 ...

  4. 《Cracking the Coding Interview》——第17章:普通题——题目13

    2014-04-29 00:15 题目:将二叉搜索树展开成一个双向链表,要求这个链表仍是有序的,而且不能另外分配对象,就地完成. 解法:Leetcode上也有,递归解法. 代码: // 17.13 F ...

  5. 了解JavaScript核心精髓(四)

    ES6 1.import与require区别 import 是同步导入js模块. require 是异步导入js模块. 2.使用let与const let con1 = 3 //与var作用相似,le ...

  6. Jmeter 参数化之 CSV Data Set Config 循环读取参数

    对于做接口和性能测试,个人感觉Jmeter是一个非常方便易学的工具,今天随笔记录Jmeter 参数化之 CSV Data Set Config. 首先在开始记录之前,先搞明白2个问题 1.什么是参数化 ...

  7. Python运算符及逻辑运算

    基本运算符 运算符用于执行程序代码运算,会针对一个以上操作数项目来进行运算.例如:2+3,其操作数是2和3,而运算符则是“+”.在计算器语言中运算符大致可以分为5种类型:算术运算符.连接运算符.关系运 ...

  8. C#共享内存

    百度:C#共享内存. 文章:C# .Net 多进程同步 通信 共享内存 内存映射文件 Memory Mapped 转 资料:UnmanagedMemoryAccessor 资料:MemoryMappe ...

  9. 【bzoj3781】小B的询问 莫队算法

    原文地址:http://www.cnblogs.com/GXZlegend/p/6803821.html 题目描述 小B有一个序列,包含N个1~K之间的整数.他一共有M个询问,每个询问给定一个区间[L ...

  10. hdu 1242 Rescue (BFS)

    Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...