使用Oozie运行Shell脚本

13

我正在尝试通过Oozie运行一个sh脚本,但是我遇到了问题:

无法在目录“/mapred/local/taskTracker/dell/jobcache/job_201312061003_0001/attempt_201312061003_0001_m_000000_0/work”中运行程序“script.sh”: java.io.IOException: error=2, 没有那个文件或目录。

请帮我提供必要的步骤。


步骤1:它存在吗? - Ry-
从oozie运行ls -la以证明它在那里。你是手动复制还是使用oozie通过<file>script.sh</file>复制的? - Oleksii
1
这类似于https://dev59.com/8H3aa4cB1Zd3GeqPfJTR,给出了很好的解释。 - Balkrishan Aggarwal
9个回答

7

这个错误信息非常模糊。以下是一些问题,这些问题帮助我解决了此问题。

-如果您在kerberized集群上运行oozie工作流,请确保通过传递您的Kerberos Keytab进行身份验证:

...
<shell>
  <exec>scriptPath.sh</exec>
  <file>scriptPath.sh</file>
  <file>yourKeytabFilePath</file>
</shell>
...

-在您的shell文件(scriptPath.sh)中,请确保删除第一行的shell引用。

#!usr/bin/bash

实际上,如果这个 shell reference 没有在所有的数据节点上部署,就会导致出现这个错误代码。


5
移除 #!usr/bin/bash 救了我的命。 - Minutis

4
因为一些非常愚蠢的原因,我遇到了同样的问题。我在工作流程中添加了一个“shell block”,然后选择了相应的sendMail.sh文件,但我忘记在“FILE”+中添加sendMail.sh文件。

enter image description here


1
尝试为HDFS提供完整路径,例如:
<exec>/user/nathalok/run.sh</exec>  
<file>/user/nathalok/run.sh#run.sh</file> 

并确保在job.properties中正确提及库和workflow.xml的路径。

oozie.libpath=hdfs://server/user/oozie/share/lib/lib_20150312161328/oozie
oozie.wf.application.path=hdfs://bcarddev/user/budaledi/Teradata_Flow

1
<exec>/hdfs路径/script.sh</exec><file>/hdfs路径/scripts#script.sh</file> 确保在第二行中加入 # - user3754136

1

workflow.xml :

...
<shell>
  <exec>script.sh</exec>

  <file>scripts/script.sh</file>
</shell>
...

请确保在hdfs的同一文件夹中拥有scripts/script.sh脚本。


1

1
除了其他人说的原因外,这也可能是由于shell脚本具有错误的行尾引起的(例如Windows的CRLF)。至少对我来说是这样的 :)

1
如果你的Shell文件存在于与项目相关的目录中,那么它的格式可能导致这个错误。你需要使用dos2linux将格式从DOS转换为Linux:dos2linux xxxx.sh。请注意,不要删除HTML标签。

谢谢。这帮了我很大的忙。我需要在脚本文件中使用 set ff=unix - Sivaprasanna Sethuraman

0

同时确保shell脚本符合UNIX标准。如果这些shell脚本是在Windows环境下编写的,则会附加Windows特定的行尾(EOL),并且这些脚本不会被oozie识别。因此,在oozie shell操作中,您将收到“找不到文件或目录”的错误提示。


0

workflow.xml 的内容大致如下

<workflow-app name="HiveQuery_execution" xmlns="uri:oozie:workflow:0.5">
<start to="shell-3c43"/>
<kill name="Kill">
    <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="shell-3c43">
    <shell xmlns="uri:oozie:shell-action:0.1">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <exec>/user/path/hivequery.sh</exec>
        <file>/user/path/hivequery.sh#hivequery.sh</file>
          <capture-output/>
    </shell>
    <ok to="End"/>
    <error to="Kill"/>
</action>
<end name="End"/>

Job.properties

jobTracker=xxxx.xxx.xxx.com:port
nameNode=hdfs://xxxx.xxx.xxx.com:port

建议通过UI进行更好的配置,如上所述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接