Oozie简单案例执行一个脚本-02https://blog.csdn.net/kxj19980524/article/details/89576687
在一个脚本的基础上修改配置文件,添加一个脚本p2.sh
编写一个新的脚本p2.sh 让它输出一个日期
为了验证oozie是工作流的形式,把p1.sh也改成输出时间,看时间上的差异
修改workflow,添加一个动作.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<workflow-app xmlns="uri:oozie:workflow:0.4" name="shell-wf">
<!-- start是先执行名字为shell-node的动作,可以随便起名 -->
<start to="p1-shell-node"/>
<action name="p1-shell-node">
<shell xmlns="uri:oozie:shell-action:0.2">
<!-- 这边的变量都是引用的job.properties里的变量 -->
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<!-- 把这个改为那边定义的脚本变量 -->
<exec>${EXEC1}</exec>
<!-- <argument>my_output=Hello Oozie</argument> -->
<file>/user/kxj/oozie-apps/shell/${EXEC1}#${EXEC1}</file>
<capture-output/>
</shell>
<!-- ok就是如果上面的动作执行成功的话跳转到哪儿,错误的话跳转到哪儿 -->
<ok to="p2-shell-node"/>
<error to="fail"/>
</action>
<action name="p2-shell-node">
<shell xmlns="uri:oozie:shell-action:0.2">
<!-- 这边的变量都是引用的job.properties里的变量 -->
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<!-- 把这个改为那边定义的脚本变量 -->
<exec>${EXEC2}</exec>
<!-- <argument>my_output=Hello Oozie</argument> -->
<file>/user/kxj/oozie-apps/shell/${EXEC2}#${EXEC2}</file>
<capture-output/>
</shell>
<!-- ok就是如果上面的动作执行成功的话跳转到哪儿,错误的话跳转到哪儿 -->
<ok to="end"/>
<error to="fail"/>
</action>
<decision name="check-output">
<switch>
<case to="end">
${wf:actionData('shell-node')['my_output'] eq 'Hello Oozie'}
</case>
<default to="fail-output"/>
</switch>
</decision>
<kill name="fail">
<message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<kill name="fail-output">
<message>Incorrect output, expected [Hello Oozie] but was [${wf:actionData('shell-node')['my_output']}]</message>
</kill>
<end name="end"/>
</workflow-app>
修改完配置文件后,重新上传,在上传前需要把之前旧的配置删除掉.
上传配置文件
执行任务
bin/oozie job -oozie http://hadoop-senior01.buba.com:11000/oozie -config oozie-apps/shell/job.properties -run
通过这个可以看到执行一次oozie,它跑了两个mapreduce程序
一个在第一个节点上运行的,一个在第二个节点上运行的.