Spark报错:Failed to locate the winutils binary in the hadoop binary path
之前在mac上调试hadoop程序(mac之前配置过hadoop环境)一直都是正常的。因为工作需要,需要在windows上先调试该程序,然后再转到linux下。程序运行的过程中,报 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.
通过断点调试、查看源码发现程序需要根据HADOOP_HOME找到winutils.exe,由于win机器并没有配置该环境变量,所以程序报 null\bin\winutils.exe。
- 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");
- }
- try {
- // couldn't find either setting for hadoop's home directory
- if (home == null) {
- throw new IOException("HADOOP_HOME or hadoop.home.dir are not set.");
- }
- if (home.startsWith("\"") && home.endsWith("\"")) {
- home = home.substring(1, home.length()-1);
- }
- // check that the home setting is actually a directory that exists
- File homedir = new File(home);
- if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) {
- throw new IOException("Hadoop home directory " + homedir
- + " does not exist, is not a directory, or is not an absolute path.");
- }
- home = homedir.getCanonicalPath();
- } catch (IOException ioe) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Failed to detect a valid hadoop home directory", ioe);
- }
- home = null;
- }
- return home;
- }
private static String HADOOP_HOME_DIR = checkHadoopHome ();
- 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();
- }
- /** a Windows utility to emulate Unix commands */
- public static final String WINUTILS = getWinUtilsPath();
- public static final String getWinUtilsPath() {
- String winUtilsPath = null;
- try {
- if (WINDOWS) {
- winUtilsPath = getQualifiedBinPath("winutils.exe");
- }
- } catch (IOException ioe) {
- LOG.error("Failed to locate the winutils binary in the hadoop binary path",
- ioe);
- }
- return winUtilsPath;
- }
找到原因后就去网上问了度娘,找到了解决方案,很简单,如下:
1.下载winutils的windows版本
GitHub上,有人提供了winutils的windows的版本,项目地址是: https://github.com/srccodes/hadoop-common-2.2.0-bin ,直接下载此项目的zip包,下载后是文件名是hadoop-common-2.2.0-bin-master.zip,随便解压到一个目录
2.配置环境变量
增加用户变量HADOOP_HOME,值是下载的zip包解压的目录,然后在系统变量path里增加$HADOOP_HOME\bin 即可。
再次运行程序,正常执行。
Spark报错:Failed to locate the winutils binary in the hadoop binary path的更多相关文章
- WIN7下运行hadoop程序报:Failed to locate the winutils binary in the hadoop binary path
之前在mac上调试hadoop程序(mac之前配置过hadoop环境)一直都是正常的.因为工作需要,需要在windows上先调试该程序,然后再转到linux下.程序运行的过程中,报Failed to ...
- 解决spark运行中failed to locate the winutils binary in the hadoop binary path的问题
1.下载hadoop-common-2.2.0-bin并解压到某个目录 https://github.com/srccodes/hadoop-common-2.2.0-bin 2.设置hadoop.h ...
- Windows本地运行调试Spark或Hadoop程序失败:ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
报错内容 ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOExce ...
- Hadoop:开发机运行spark程序,抛出异常:ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
问题: windows开发机运行spark程序,抛出异常:ERROR Shell: Failed to locate the winutils binary in the hadoop binary ...
- Windows7系统运行hadoop报Failed to locate the winutils binary in the hadoop binary path错误
程序运行的过程中,报Failed to locate the winutils binary in the hadoop binary path Java.io.IOException: Could ...
- 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 ...
- windows本地调试安装hadoop(idea) : ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
1,本地安装hadoop https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/ 下载hadoop对应版本 (我本意是想下载hadoop ...
- ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
文章发自:http://www.cnblogs.com/hark0623/p/4170172.html 转发请注明 14/12/17 19:18:53 ERROR Shell: Failed to ...
- spark报错处理
Spark报错处理 1.问题:org.apache.spark.SparkException: Exception thrown in awaitResult 分析:出现这个情况的原因是spark启动 ...
随机推荐
- HDU 2276 矩阵快速幂
Kiki & Little Kiki 2 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java ...
- Java HashMap的工作原理
面试的时候经常会遇见诸如:”java中的HashMap是怎么工作的”.”HashMap的get和put内部的工作原理”这样的问题. 本文将用一个简单的例子来解释下HashMap内部的工作原理. 首先我 ...
- 004——php字符串中处理函数(三)
<?php /** * 字符串替换函数: * str_replace(); 替换字符串或数组元素,区分大小写,第四个参数可选,用于统计替换次数 * str_ireplace()不区分大小写替换 ...
- Win7操作系统安装IE10提示“安装前需要更新与安装程序版本”
安装IE10浏览器时提示错误的 Internet Explorer安装程序版本 故障现象: Win7操作系统在安装IE10浏览器时会弹出对话框,提示错误的Ieternet Explorer 安装程序版 ...
- Kotlin Reference (十) Interfaces
most from reference 接口 Kotlin中的接口非常类似于Java8,它们可以包含抽象方法的声明以及方法实现.与抽象类不同的是接口不能存储状态.它们可以具有属性,但这些需要是抽象的或 ...
- LTIB for ubuntu12.04
在 ltib 目录中执行以下代码: cd <your ltib folder>./patch-ltib-ubuntu12.04.shpatch -p1 < patch-dist-u ...
- StringUtils的工具类isBlank与isEmply
1. public static boolean isEmpty(String str) 判断某字符串是否为空,为空的标准是 str==null 或 str.length()==0 下面是 S ...
- SimpleDateFormat格式化日期以及日期的相关操作
一.Java中的日期概述 日期在Java中是一块非常复杂的内容,对于一个日期在不同的语言国别环境中,日期的国际化,日期和时间之间的转换,日期的加减运算,日期的展示格式都是非常复杂的问题. 在J ...
- 我的AOP那点事儿--1
题记:一段时间以来一直想整理下关于AOP的知识,之前一直停留在会怎么使用AOP,关于AOP的深入点儿的知识就不知所以然了,正好项目上刚好用到需要用AOP实现的功能,所以找个时间统一整理下就很有必要了. ...
- vmware克隆linux网络配置
一.配置Linux网络 在安装Linux的时候,一定要保证你的物理网络的IP是手动设置的,要不然会在Linux设置IP连通网络的时候会报network is unreachable 并且怎么也找不到问 ...