报错如下:

300 [main] DEBUG org.apache.hadoop.util.Shell  - Failed to detect a valid hadoop home directory
java.io.IOException: HADOOP_HOME or hadoop.home.dir are not set

解决办法一:

根据 http://blog.csdn.net/baidu_19473529/article/details/54693523 配置hadoop_home变量

下载winutils地址https://github.com/srccodes/hadoop-common-2.2.0-bin下载解压

重新打开Eclipse,运行程序,可以解决内网的Hadoop连接问题。(亲测试通过)

解决办法二:

在java程序中加入

System.setProperty("hadoop.home.dir", "/usr/local/hadoop-2.6.0");

依然报错(未亲测试)

解决办法三:(不是同一问题?)

根据该提示:

依然报错

--------------------------------5.19.早晨------------------------------------------

今天早上再次执行该程序,将上传到HDFS部分的代码给注释掉后发现日志报错信息如下:

132 [main] DEBUG org.apache.hadoop.util.NativeCodeLoader  - Trying to load the custom-built native-hadoop library...
134 [main] DEBUG org.apache.hadoop.util.NativeCodeLoader - Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: no hadoop in java.library.path

1)check Hadoop library:

root@Ubuntu-1:/usr/local/hadoop-2.6.0/lib/native# file libhadoop.so.1.0.

It's 64-bite library

2)Try adding the HADOOP_OPTS environment variable:

root@Ubuntu-1:~# vi /etc/profile                            //environment variable
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native/"

It doesn't work, and reports the same error.

3)Try adding the HADOOP_OPTS and HADOOP_COMMON_LIB_NATIVE_DIR environment variable:

export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_HOME}/lib/native

export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/"

It still doesn't work, and reports the same error.

4)Adding the Hadoop library into LD_LIBRARY_PATH

root@Ubuntu-1:~# vi .bashrc 
export LD_LIBRARY_PATH=/usr/local/hadoop/lib/native/:$LD_LIBRARY_PATH

It doesn't work, and reports the same error.

5)append word native to HADOOP_OPTS like this

export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$HADOOP_HOME/lib/native"

It doesn't work, and reports the same error.

-----------------------------------5.20早晨-------------------------

win下依旧无法使用java代码上传文件到HDFS

----------------------------------5.24------------

copy了一份hadoop-2.6.0文件到本机,更改bin目录和path ,显示无效的path,遂更改回去

---------------------2017.5.26-------------------

今天早上开机 试了一下 发现它已经好了  其实上述的设置已经可以解决大部分遇到这类问题的人群

 

关于java.io.IOException: HADOOP_HOME or hadoop.home.dir are not set.的问题的更多相关文章

  1. windows 中使用hbase 异常:java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

    平时一般是在windows环境下进行开发,在windows 环境下操作hbase可能会出现异常(java.io.IOException: Could not locate executable nul ...

  2. 排查Hive报错:org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start of Array expected

    CREATE TABLE json_nested_test ( count string, usage string, pkg map<string,string>, languages ...

  3. 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 ...

  4. hive运行query语句时提示错误:org.apache.hadoop.ipc.RemoteException: java.io.IOException: java.io.IOException:

    hive> select product_id, track_time from trackinfo limit 5; Total MapReduce jobs = 1 Launching Jo ...

  5. 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 ...

  6. 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 ...

  7. idea 提示:ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException解决方法

    Windows系统中的IDEA链接Linux里面的Hadoop的api时出现的问题 提示:ERROR util.Shell: Failed to locate the winutils binary ...

  8. org.apache.hadoop.ipc.RemoteException(java.io.IOException)

    昨晚突然之间mr跑步起来了 jps查看 进程都在的,但是在reduce任务跑了85%的时候会抛异常 异常情况如下: 2016-09-21 21:32:28,538 INFO [org.apache.h ...

  9. 运行基准测试hadoop集群中的问题:org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /benchmarks/TestDFSIO/io_data/test_

    在master(即:host2)中执行 hadoop jar hadoop-test-1.1.2.jar DFSCIOTest -write -nrFiles 12 -fileSize 10240 - ...

随机推荐

  1. C# Liseview的使用方法之一:滚动到选中的行

    listview.items[i].EnsureVisible();//滚动到你想要显示出来的行上. 其中,listview.items[i]就是你想要显示的行.

  2. Java学习04 (第一遍)

    封装.抽象.继承和多态.封装:在面向对象语言中,封装特性是由类来体现的,我们将现实生活中的一类实体定义成类,其中包括属性和行为(在Java中就是方法),就好像人类,可以具有name,sex,age等属 ...

  3. 吴裕雄 python神经网络 水果图片识别(3)

    import osimport kerasimport timeimport numpy as npimport tensorflow as tffrom random import shufflef ...

  4. Nginx入门安装升级

    1).Nginx ("engine x") 是一个高性能HTTP 和 反向代理 服务器.IMAP.POP3.SMTP 服务器. Nginx特点是占有内存少,并发能力强,事实上Ngi ...

  5. ServiceWork的五种状态

    [ServiceWork的五种状态] installing.installed.activating.activated.redundant 参考:https://developer.mozilla. ...

  6. .resources文件转为可视化.resx文件

    ResGen.exe启动闪退.--方法不对 参考:http://www.opdown.com/soft/101205.html 在cmd中启动ResGen.exe. 打开cmd:输入 C:\Windo ...

  7. apache服务器伪静态配置说明

    apache服务器伪静态配置说明: 第一种 .如果是多城市版分类并且使用了城市二级域名即(多城市+多域名),请修改apache的配置文件,把以下代码添加到配置文件的最后一行即可,注意把qibosoft ...

  8. Neumann's Principle and Curie laws

    Neumann's Principle Neumann's principle, or principle of symmetry, states that, if a crystal is inva ...

  9. 7. Reverse Integer (整数的溢出)

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 For the p ...

  10. View 常用方法

    id layout_width layout_height layout_margin.layout_marginTop minWidth minHeight background layout_gr ...