报错如下:

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. 通过AI自学习,Google让Pixel 3的人像模式更优秀

    通过AI自学习,Google让Pixel 3的人像模式更优秀 Link: https://news.cnblogs.com/n/613720/ 虽然双摄手机已经在市场上普及,其所带来的人像模式.多倍变 ...

  2. vc读取当前路径和读取配置ini文件

    //获取路径 std::string GetApplicationDir() { HMODULE hModule = GetModuleHandleW(NULL); WCHAR wpath[MAX_P ...

  3. 使用 COM 类库创建链接桌面快捷方式

    用到的 COM 类库: Windows Script Host Object Model --> Interop.IWshRuntimeLibrary.dll 示例代码: private sta ...

  4. 吴裕雄 04-mysql创建数据库

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin'; CREATE DATABASE 数据库名 ...

  5. Bdfproxy

    基于流量劫持动态注入shellcode 本机IP:192.168.1.113 靶机IP:192.168.1.114 先安装bdfproxy,mitmproxy,backdoor_factory 开启流 ...

  6. STOP OUR NEGATIVE THOUGHTS

    Do you ever feel like you're in over your head and at any moment you're going to burst? You're not a ...

  7. postman发送json请求

    简介: postman是一个很好的http模拟器,在测试rest服务时是很好用的工具,可以发送get.post.put等各种请求. 发送json的具体步骤: 1.选择post请求方式,同时将heade ...

  8. 合并两个排序的链表(python)

    题目描述 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. # -*- coding:utf-8 -*- # class ListNode: # def _ ...

  9. 使用ffmpeg解码 需要注意的内存泄漏问题

    说说项目中遇到的两点失误: 1. AVFrame结构,av_frame_alloc申请内存,av_frame_free释放内存.容易混淆的是av_frame_unref,它的作用是释放音视频数据资源, ...

  10. Shell教程 之test命令

    Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值.字符和文件三个方面的测试. 1.数字测试 参数 说明 -eq 等于则为真 -ne 不等于则为真 -gt 大于则为真 -ge 大于 ...