我有一个工作流程 oozie
. 在这个工作流中,我想传递一个表名作为参数。表名存在于文件中 tables.txt
我想把表名从 tables.txt
到工作流。
<workflow-app name="Shell_test" xmlns="uri:oozie:workflow:0.5">
<start to="shell-8f63"/>
<kill name="Kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="test_shell">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>shell.sh</exec>
<argument>${table}</argument>
<env-var>HADOOP_USER_NAME=${wf:user()}</env-var>
<file>/user/oozie/lib/test_shell.sh#shell.sh</file>
<file>/user/oozie/input/tables.txt#tables.txt</file>
</shell>
<ok to="End"/>
<error to="email-error"/>
</action>
<action name="email-error">
<email xmlns="uri:oozie:email-action:0.2">
<to>xxxxxxxxxx.com</to>
<subject>Status of workflow ${table}</subject>
<body>The workflow ${table} ${wf:id()} had issues and was killed. The error message is: ${wf:errorMessage(wf:lastErrorNode())}</body>
<content_type>text/plain</content_type>
</email>
<ok to="end"/>
<error to="end"/>
</action>
<end name="End"/>
</workflow-app>
我可以使用工作流中的以下命令来完成此操作。
<argument>${input_file}</argument>
<env-var>HADOOP_USER_NAME=${wf:user()}</env-var>
<file>/user/oozie/lib/test_shell.sh#shell.sh</file>
<file>/user/oozie/input/${input_file}#${input_file}</file>
现在我有个问题。
假设工作流对中的某个表失败 input_file
那我就没有收到任何电子邮件了。我收到电子邮件,只有当工作流失败的最后一个表中 input_file
.
为什么会发生这种情况?我如何在每次工作流失败时收到电子邮件?
或者我整个过程都做错了。
请任何人解释一下,纠正我在哪里做错了事情。
我的 test_shell.sh
```
while read line ;do
spark-submit --name "SparkJob" --master "yarn-client" test.py $line
done < tables.txt
1条答案
按热度按时间brccelvz1#
shell操作不会表现为shh操作,因为shell操作工作流将在其中一个数据节点上运行它将把脚本错误视为警告,除非您在脚本中退出1。另一种在失败时接收电子邮件的方法是在脚本中使用email实用程序,在执行exit 1之前是这样的
echo 'script X returned an error due to some reason; Please check the workflow for validation' | mailx -r oozie -s 'SUBJECTTOEMAIL' email@someemail.com
要使电子邮件实用程序从数据节点工作,请确保您的数据节点已安装电子邮件实用程序。如果没有安装,您可以在电子邮件部分对您的边缘节点执行ssh,如下所示ssh -o StrictHostKeyChecking=no ${edgeUser}@${edgeHost} "echo 'script X returned an error due to some reason; Please check the workflow for validation' | mailx -r oozie -s 'SUBJECTTOEMAIL' email@someemail.com"
我可以建议您对您的工作流程进行一些更改,这可能会在反映错误和在工作流程中使用电子邮件操作方面给您带来更好的结果不要从shell操作本身调用配置文件,相反,可以执行以下操作
如果您注意到我对您的工作流所做的更改,我只是将tables.txt作为文件调用,而不是通过删除#tables.txt将其作为执行
当您这样做时,shell操作实际上会复制该文件并将其存储在正在运行的容器中,因此要利用table.txt config文件,在脚本中您将这样调用
. ./tables.txt
因为容器已经复制了,所以您可以按主目录中的方式调用tables.txt。希望,这将帮助你。。。!!!如果您对我建议的解决方案有任何疑问,请发表意见。