问题:如何在workflow.xml中添加shell脚本?
1、在job.properties中添加要执行的脚本的名字:
2、脚本tim.sh的输入内容为:
#!/bin/bash
curl http://114.55.28.121
3、编辑workflow.xml的内容如下:
<workflow-app xmlns="uri:oozie:workflow:0.4" name="shell-wf">
<start to="shell-node"/>
<action name="shell-node">
<shell xmlns="uri:oozie:shell-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>${statEndNoticeShell}</exec>
<argument></argument>
<file>${statEndNoticeShell}</file>
<capture-output/>
</shell>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
其中:<exec>脚本名</exex>是执行脚本的命令, <file>脚本的具体位置</file>存放脚本的位置,从项目的根目录算起。
4、将修改的workflow.xml和 tim.sh 文件上传到hdfs 上,这里我们上传目录为:
oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/apps/map-reduce
5、执行调度命令:
oozie job -ooziehttp://ssp-hadoop-01:11000/oozie -config job.properties -run
补充知识点:
job.properties是在本地服务器上,而workflow.xml文件和 tim.sh要上传到hdfs上。
由于执行shell命令的过程我们无法得知,这里通过curl去调用某一台Linux 服务器,此时我们可以利用tcpdump 命令监控这台Linux 服务器是否被调用。具体的命令为:
sudo tcpdump -i eth1 port 80 and host 114.55.92.41
用法参见:如何利用tcpdump来确定外部设备是否连接到服务器?