oozie调用shell脚本

2021-04-27 11:52:18 浏览数 (2)

job.properties

代码语言:javascript复制
nameNode=hdfs://cdh01:8020
resourceManager=cdh01:8032
queueName=default
examplesRoot=examples

oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/apps/ssh
exec=log.sh
shellpath=${nameNode}/user/${user.name}/${examplesRoot}/apps/ssh

workflow.xml

代码语言:javascript复制
  <workflow-app xmlns="uri:oozie:workflow:1.0" name="shell-wf">
    <start to="shell-ssh"/>
    <action name="shell-ssh">
        <ssh xmlns="uri:oozie:ssh-action:0.1">       
            <host>root@cdh01</host>
            <command>echo</command>
            <args>"hello world!</args>
        </ssh>
        <ok to="shell-node"/>
        <error to="fail"/>
    </action>
    <action name="shell-node">
        <shell xmlns="uri:oozie:shell-action:1.0">
            <resource-manager>${resourceManager}</resource-manager>
            <name-node>${nameNode}</name-node>          
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <exec>${exec}</exec>
            <file>${shellpath}</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>

log.sh

代码语言:javascript复制
#!/bin/bash

echo "-------开始执行---------"

$(date >> /home/example/oozie/ssh/date.log)

echo "-------执行结束----------"

0 人点赞