2019-03-10


本篇文章旨在阐述本人在某一特定情况下遇到 Hive 执行 MapReduce 作业的问题的探索过程与解决方案。不对文章的完全、绝对正确性负责。

解决方案

Hive 的配置文件  hive-site.xml 中的 hive.exec.scratchdir 的目录地址要放在 HDFS 上。


问题现象

本人在使用 Hive 执行 MapReduce 作业时,突然发现所有作业均无法执行。下达 HQL 命令的控制台只有短短几行输出。控制台输出内容如下:

 WARNING: Hive-on-MR is deprecated in Hive  and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive .X releases.
Query ID = chorm_20190310001344_e4ed74d8---aa6f-d3a1a2a60698
Total jobs =
Launching Job out of
Number of reduce tasks determined at compile time:
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Starting Job = job_1552147755103_0003, Tracking URL = http://m254:8088/proxy/application_1552147755103_0003/
Kill Command = /usr/bigdata/hadoop/bin/hadoop job -kill job_1552147755103_0003
Hadoop job information for Stage-: number of mappers: ; number of reducers:
-- ::, Stage- map = %, reduce = %
Ended Job = job_1552147755103_0003 with errors
Error during job, obtaining debugging information...
FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
MapReduce Jobs Launched:
Stage-Stage-: HDFS Read: HDFS Write: FAIL
Total MapReduce CPU Time Spent: msec

开始时感觉很莫名其妙,因为之前还好好的,突然就出现这种现象。在网上似乎也搜索不到这个问题的解决方案。所幸经过一番折腾后,找到了问题原因所在。

探索过程

首先基本可以确定,在控制台上打印的信息无法帮助定位问题原因与作出解决方案假设。所以要另寻它法。

1. 检查 Hadoop 与 YARN 是否正常工作。

Hadoop 好检查。直接通过网页 UI 与 CLI 来检查即可。本人这里确认了 Hadoop 没有问题。

随后是 YARN ,也是通过网页 UI 来检查。同时不要忘记检查集群中各机器的对应进程是否在正常运行。本人这块经检查也没有问题。

最后再检查一下 MapReduce ,我这里直接通过 Hadoop 自带的 example.jar 来跑一个 wordcount 例子来检查。经检查也 OK 。

经过上面 3  步的检查,排除了 Hadoop 的问题。

2. 检查 Hive

说实话,这个检查不出什么来。也不知道该怎么来检查。

3. 查看 YARN 中这个作业的日志

老实说,出现问题的时候应该第一时刻就来查看日志的,但是在这里不知怎么犯傻了。

打开 http://yarn-host:8080 网页,找到那条错误的作业记录,点进去,发现有如下错误信息:

 Diagnostics:
Application application_1552147755103_0003 failed times due to AM Container for appattempt_1552147755103_0003_000002 exited with exitCode: -
For more detailed output, check application tracking page:http://m254:8088/cluster/app/application_1552147755103_0003Then, click on links to logs of each attempt.
Diagnostics: File file:/var/bigdata/hive/scratchdir/chorm/46b600b8--48c8--a2f6b649bcae/hive_2019--10_00--44_741_6711852286526745896-/-mr-/cd1fe621-e494-4ddd-b8f8-a9c80e052c6c/reduce.xml does not exist
java.io.FileNotFoundException: File file:/var/bigdata/hive/scratchdir/chorm/46b600b8--48c8--a2f6b649bcae/hive_2019--10_00--44_741_6711852286526745896-/-mr-/cd1fe621-e494-4ddd-b8f8-a9c80e052c6c/reduce.xml does not exist
at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:)
at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:)
at org.apache.hadoop.yarn.util.FSDownload.copy(FSDownload.java:)
at org.apache.hadoop.yarn.util.FSDownload.access$(FSDownload.java:)
at org.apache.hadoop.yarn.util.FSDownload$.run(FSDownload.java:)
at org.apache.hadoop.yarn.util.FSDownload$.run(FSDownload.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:)
at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:)
at java.util.concurrent.FutureTask.run(FutureTask.java:)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:)
at java.util.concurrent.FutureTask.run(FutureTask.java:)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
at java.lang.Thread.run(Thread.java:) Failing this attempt. Failing the application.

从上面日志中发现一条重要信息 reduce.xml does not exists! 。reduce.xml 似乎是 MapReduce 作业相关的文件,所以判断可能是某个或某些和作业执行相关的配置文件缺失,导致作业无法进行下去。然后猛然想起之前自己有改动过 Hive 的配置信息,将属性 hive.exec.scratchdir 指向的目录从 HDFS 上改到了本地文件系统中。然后这条属性就是和 Hive 的作业执行相关的。这条属性指向的目录专门用于存储 Hive 的 MapReduce 作业的阶段执行计划和中间产物的。 Hive 的作业一般都会在集群中执行,现在我将它指向某台机器的本地目录,导致作业中间文件无法在集群中共享,所以作业肯定是不能正常执行的。

在将 hive.exec.scratchdir 属性指向的目录重新设定到 HDFS 中以后,Hive 的 MapReduce 作业就能正常执行了。

Hive 执行作业时报错 [ Diagnostics: File file:/ *** reduce.xml does not exist FileNotFoundException: File file:/ ]的更多相关文章

  1. Hadoop执行作业时报错:java.lang.OutOfMemoryError: Java heap space

    常常被一些用户问到,说“为什么我的mapreduce作业总是运行到某个阶段就报出如下错误,然后失败呢?以前同一个作业没出现过的呀?” 10/01/10 12:48:01 INFO mapred.Job ...

  2. mysql启动时报错:Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid)

    mysql启动报错Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.p ...

  3. 执行automake时报错 error while making link: Operation not supported

    执行automake时报错: [root@localhost project]# automake --add-missingconfigure.in: installing `./install-s ...

  4. 启动azkaban时出现User xml file conf/azkaban-users.xml doesn't exist问题解决(图文详解)

      问题详情 [hadoop@master azkaban]$ ll total drwxrwxr-x hadoop hadoop May : azkaban- drwxrwxr-x hadoop h ...

  5. npm安装socket.io时报错的解决方法(npm WARN enoent ENOENT: no such file or directory, open '/usr/local/nodejs/bin/package.json')

    执行 npm install socket.io安装时报错: [root@WEB node_modules]# npm install socket.ionpm WARN enoent ENOENT: ...

  6. 编译gd-2.0.35.tar.gz时报错:gd_png.c:16:53: error: png.h: No such file or directory

    编译gd-2.0.35.tar.gz时报错: gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/local/freetype/include/freetype2 -I/us ...

  7. RHEL 6.5----apr-util1.6执行make时报错

    报错信息 ]: Entering directory `/usr/local/src/apr-util-' /bin//build-/libtool --silent --mode=compile / ...

  8. 登录用户执行sudo时报错

    场景: 以普通用户登录,登陆后切换至root或其他用户时报错(sudo su -或sudo -i) 报错信息: -bash: /bin/logger: Argument list too long 根 ...

  9. IIS导入.pfx证书时报错:"A specified logon session does not exist. It may already have been terminated."

    在IIS中可以直接导入.pfx文件来给站点绑定https协议: 如果在导入.pfx文件时,不选择"Allow this certificate to be exported"的话 ...

随机推荐

  1. HTML5跳转页面并传值以及localStorage的用法

    1.首先,你得在那个页面把数据存入localStorage中吧.这个是必须的! localStorage.setItem("user",JSON.stringify(data.al ...

  2. javascript进阶之AJAX

    AJAX 一 AJAX预备知识:json进阶 1.1 什么是JSON? JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.JSON是用字符串来表示Javas ...

  3. 用WijmoJS搭建您的前端Web应用 —— React

    前文回顾 在本系列文章中,我们已经介绍了Angular和Vue框架下 WijmoJS 的玩法. 而今天,我们将展示如何使用 WijmoJS 来搭建一款具备独特创新性.出色性能和简单代码逻辑的 Reac ...

  4. 【eclipse】mybatis配置文件创建与mapper接口文件创建

    什么是mybatis: MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. mybatis配置文件: <?xml version="1.0" ...

  5. MFC自绘菜单

    自绘控件问题多多.本文以菜单为例. ①当要使用顶层菜单资源.对话框资源.状态栏资源等这3种资源的任何一种.那么CWinApp::InitInstance函数内部必须使用LoadFrame函数来加载资源 ...

  6. 用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列。

    数据库中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列. 方法一: select (case when a>b then a el ...

  7. Docker资源限制

    我们在容器中运行docker镜像的时候,可以指定一些设置容器cpu和内存的相关参数来进行限制,这样子尽量把容器资源做的相对稳定一些.这些参数是在docker run/create命令使用,比如: -- ...

  8. LeetCode算法题-Non-decreasing Array(Java实现)

    这是悦乐书的第283次更新,第300篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第151题(顺位题号是665).给定一个包含n个整数的数组,您的任务是通过修改最多1个元 ...

  9. Mockito单元测试

    Mockito简介 Mockito是一个单元测试框架,需要Junit的支持.在我们的项目中,都存在相当多的依赖关系,当我们在测试某一个业务相关的接口或则方法时,绝大多数时候是没有办法或则很难去添加所有 ...

  10. 多线程控制工具类--倒计时器CountDownLatch的使用(模仿火箭发射)

    package com.thread.test.Lock; import java.util.Random; import java.util.concurrent.CountDownLatch; i ...