Hive 執行作業時報錯 [ Diagnostics: File file:/ *** reduce.xml does not exist FileNotFoundException: File file:/ ]


2019-03-10

 


 

本篇文章旨在闡述本人在某一特定情況下遇到 Hive 執行 MapReduce 作業的問題的探索過程與解決方案。不對文章的完全、絕對正確性負責。

 

解決方案

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

 


 

問題現象

本人在使用 Hive 執行 MapReduce 作業時,突然發現所有作業均無法執行。下達 HQL 命令的控制台只有短短幾行輸出。控制台輸出內容如下:

 1 WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
 2 Query ID = chorm_20190310001344_e4ed74d8-4048-4918-aa6f-d3a1a2a60698
 3 Total jobs = 1
 4 Launching Job 1 out of 1
 5 Number of reduce tasks determined at compile time: 1
 6 In order to change the average load for a reducer (in bytes):
 7   set hive.exec.reducers.bytes.per.reducer=<number>
 8 In order to limit the maximum number of reducers:
 9   set hive.exec.reducers.max=<number>
10 In order to set a constant number of reducers:
11   set mapreduce.job.reduces=<number>
12 Starting Job = job_1552147755103_0003, Tracking URL = http://m254:8088/proxy/application_1552147755103_0003/
13 Kill Command = /usr/bigdata/hadoop/bin/hadoop job  -kill job_1552147755103_0003
14 Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
15 2019-03-10 00:13:47,528 Stage-1 map = 0%,  reduce = 0%
16 Ended Job = job_1552147755103_0003 with errors
17 Error during job, obtaining debugging information... 18 FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask 19 MapReduce Jobs Launched: 
20 Stage-Stage-1:  HDFS Read: 0 HDFS Write: 0 FAIL
21 Total MapReduce CPU Time Spent: 0 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 網頁,找到那條錯誤的作業記錄,點進去,發現有如下錯誤信息:

 1 Diagnostics: 
 2 Application application_1552147755103_0003 failed 2 times due to AM Container for appattempt_1552147755103_0003_000002 exited with exitCode: -1000 
 3 For more detailed output, check application tracking page:http://m254:8088/cluster/app/application_1552147755103_0003Then, click on links to logs of each attempt. 
 4 Diagnostics: File file:/var/bigdata/hive/scratchdir/chorm/46b600b8-9250-48c8-8284-a2f6b649bcae/hive_2019-03-10_00-13-44_741_6711852286526745896-1/-mr-10005/cd1fe621-e494-4ddd-b8f8-a9c80e052c6c/reduce.xml does not exist  5 java.io.FileNotFoundException: File file:/var/bigdata/hive/scratchdir/chorm/46b600b8-9250-48c8-8284-a2f6b649bcae/hive_2019-03-10_00-13-44_741_6711852286526745896-1/-mr-10005/cd1fe621-e494-4ddd-b8f8-a9c80e052c6c/reduce.xml does not exist 
 6 at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:611) 
 7 at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:824) 
 8 at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:601) 
 9 at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:428) 
10 at org.apache.hadoop.yarn.util.FSDownload.copy(FSDownload.java:253) 
11 at org.apache.hadoop.yarn.util.FSDownload.access$000(FSDownload.java:63) 
12 at org.apache.hadoop.yarn.util.FSDownload$2.run(FSDownload.java:361) 
13 at org.apache.hadoop.yarn.util.FSDownload$2.run(FSDownload.java:359) 
14 at java.security.AccessController.doPrivileged(Native Method) 
15 at javax.security.auth.Subject.doAs(Subject.java:422) 
16 at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1758) 
17 at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:359) 
18 at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:62) 
19 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
20 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
21 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
22 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
23 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
24 at java.lang.Thread.run(Thread.java:748) 
25 
26 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 作業就能正常執行了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM