首页 > 代码库 > Oozie-自定义实现WorkFlow中shell action

Oozie-自定义实现WorkFlow中shell action

    1. 拷贝默认的shell目录来进行修改
      $ cp -r ./examples/apps/shell/ my-apps/
    2. 定义job.properties
      nameNode=hdfs://bigdata-00:8020
      jobTracker=bigdata-00:8032
      queueName=default
      examplesRoot=user/wulei/my-apps/shell
      #定义workflow.xml路劲
      oozie.wf.application.path=${nameNode}/${examplesRoot}/workflow.xml
      #定义一个变量名存储shell文件名
      EXEC=oozie.sh
    3. 定义workflow.properties
      <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>${EXEC}</exec>
               <!-- 定义shell脚本路劲 -->
               <file>${nameNode}/${examplesRoot}/${EXEC}#${EXEC}</file> <!--Copy the executable to compute node‘s current working directory -->
           </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>
    4. 定义要实现的脚本
      技术分享
      19.png
    5. 上传到hdfs后运行
      技术分享
      20.png
    6. 查看运行结果
      技术分享
      21.png

      技术分享
      22.png

Oozie-自定义实现WorkFlow中shell action