启动Hive CLI(基于Tez)因资源本地化失败求助
Hive CLI启动时Tez资源本地化失败问题排查
问题描述
启动Hive CLI时出现Tez资源本地化失败,报错日志如下:
2023-07-08 10:00:46,822 INFO [main] tez.DagUtils (DagUtils.java:localizeResource(1159)) - Localizing resource because it does not exist: file:/home/hadoop/tez/tez.0.10 to dest: hdfs://HostName:9000/tmp/hive/hadoop/_tez_session_dir/9cfed3fe-ac8a-411f-a54e-900ede1b7304-resources/tez.0.10 2023-07-08 10:00:49,788 INFO [main] tez.DagUtils (DagUtils.java:localizeResource(1182)) - Looks like another thread or process is writing the same file 2023-07-08 10:00:49,792 INFO [main] tez.DagUtils (DagUtils.java:checkOrWaitForTheFile(1211)) - Waiting for the file hdfs://Hostname:9000/tmp/hive/hadoop/_tez_session_dir/9cfed3fe-ac8a-411f-a54e-900ede1b7304-resources/tez.0.10 (5 attempts, with 5000ms interval) 2023-07-08 10:01:14,829 ERROR [main] tez.DagUtils (DagUtils.java:localizeResource(1190)) - Could not find the jar that was being uploaded Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Previous writer likely failed to write hdfs://Hostname:9000/tmp/hive/hadoop/_tez_session_dir/9cfed3fe-ac8a-411f-a54e-900ede1b7304-resources/tez.0.10. Failing because I am unlikely to write too. at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:683) at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:591) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:747) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:318) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) Caused by: java.io.IOException: Previous writer likely failed to write hdfs://Hostname:9000/tmp/hive/hadoop/_tez_session_dir/9cfed3fe-ac8a-411f-a54e-900ede1b7304-resources/tez.0.10. Failing because I am unlikely to write too. at org.apache.hadoop.hive.ql.exec.tez.DagUtils.localizeResource(DagUtils.java:1191) at org.apache.hadoop.hive.ql.exec.tez.DagUtils.addTempResources(DagUtils.java:1042) at org.apache.hadoop.hive.ql.exec.tez.DagUtils.localizeTempFilesFromConf(DagUtils.java:931) at org.apache.hadoop.hive.ql.exec.tez.TezSessionState.ensureLocalResources(TezSessionState.java:610) at org.apache.hadoop.hive.ql.exec.tez.TezSessionState.openInternal(TezSessionState.java:287) at org.apache.hadoop.hive.ql.exec.tez.TezSessionState.beginOpen(TezSessionState.java:256) at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:680) ... 9 more
已尝试将所有Tez JAR复制到/home/hadoop/tez/路径,但问题仍未解决,寻求技术帮助。
排查解决方案
1. 清理HDFS临时目录
手动删除残留的Tez会话临时文件,避免不完整文件或锁干扰:
# 删除指定会话的资源目录 hdfs dfs -rm -r /tmp/hive/hadoop/_tez_session_dir/9cfed3fe-ac8a-411f-a54e-900ede1b7304-resources/ # 或清理整个Tez会话目录 hdfs dfs -rm -r /tmp/hive/hadoop/_tez_session_dir/
2. 检查文件权限与所有权
确保本地Tez JAR和HDFS目标路径的权限正确,hadoop用户拥有读写权限:
# 检查本地文件权限 ls -l /home/hadoop/tez/tez.0.10 # 修正权限(若需要) chown hadoop:hadoop /home/hadoop/tez/tez.0.10 chmod 644 /home/hadoop/tez/tez.0.10 # 检查HDFS路径权限 hdfs dfs -ls /tmp/hive/hadoop/ # 修正HDFS路径权限(若需要) hdfs dfs -chown -R hadoop:hadoop /tmp/hive/hadoop/ hdfs dfs -chmod -R 755 /tmp/hive/hadoop/
3. 修正Tez配置指向
修改Hive配置,将tez.lib.uris指向HDFS上的Tez压缩包而非本地路径,避免重复本地化:
编辑hive-site.xml,确认配置:
<property> <name>tez.lib.uris</name> <value>hdfs://HostName:9000/apps/tez/tez.tar.gz</value> </property>
提前将Tez压缩包上传至HDFS对应路径,确保所有节点可访问。
4. 验证Tez JAR完整性
检查本地Tez JAR是否损坏,对比MD5值:
# 生成本地文件MD5 md5sum /home/hadoop/tez/tez.0.10 # 若已上传HDFS,对比远程文件MD5 hdfs dfs -cat /tmp/hive/hadoop/_tez_session_dir/.../tez.0.10 | md5sum
若MD5不一致,重新上传完整的Tez JAR文件。
5. 关闭冲突会话
终止正在运行的Tez作业或Hive会话,避免线程竞争写文件:
# 查看当前YARN应用 yarn application -list # 杀掉冲突的Tez应用 yarn application -kill <application-id>
内容的提问来源于stack exchange,提问作者Kaher
相关产品推荐
相关产品推荐

