• Oozie 集成 Shell


    1) prepare shell case
    $ cd ~/work/oozie-5.2.1
    $ tree oozie/apps/shell

    1. oozie/apps/shell
    2. ├── hello.sh
    3. ├── job.properties
    4. └── workflow.xml

    $ cat oozie/apps/shell/hello.sh

    1. #!/bin/sh
    2. echo "my_output=Hello Oozie"

    $ cat oozie/apps/shell/job.properties

    1. nameNode=hdfs://localhost:9000
    2. resourceManager=localhost:8032
    3. queueName=default
    4. oozieRoot=user/${user.name}/oozie
    5. oozie.wf.application.path=${nameNode}/${oozieRoot}/apps/shell
    6. EXEC=hello.sh

    $ cat oozie/apps/shell/workflow.xml

    1. <workflow-app xmlns="uri:oozie:workflow:1.0" name="shell-wf">
    2. <start to="shell-node"/>
    3. <action name="shell-node">
    4. <shell xmlns="uri:oozie:shell-action:1.0">
    5. <resource-manager>${resourceManager}</resource-manager>
    6. <name-node>${nameNode}</name-node>
    7. <configuration>
    8. <property>
    9. <name>mapred.job.queue.name</name>
    10. <value>${queueName}</value>
    11. </property>
    12. </configuration>
    13. <exec>${EXEC}</exec>
    14. <file>${nameNode}/${oozieRoot}/apps/shell/${EXEC}#${EXEC}</file>
    15. <capture-output/>
    16. </shell>
    17. <ok to="check-output"/>
    18. <error to="fail"/>
    19. </action>
    20. <decision name="check-output">
    21. <switch>
    22. <case to="end">
    23. ${wf:actionData('shell-node')['my_output'] eq 'Hello Oozie'}
    24. </case>
    25. <default to="fail-output"/>
    26. </switch>
    27. </decision>
    28. <kill name="fail">
    29. <message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    30. </kill>
    31. <kill name="fail-output">
    32. <message>Incorrect output, expected [Hello Oozie] but was [${wf:actionData('shell-node')['my_output']}]</message>
    33. </kill>
    34. <end name="end"/>
    35. </workflow-app>

    2) upload to hdfs
    $ hdfs dfs -put oozie/apps/shell oozie/apps/

    3) run and check
    $ bin/oozie job -config oozie/apps/shell/job.properties -run
    job: 0000004-220629164930563-oozie-sun_-W
    $ bin/oozie job -info 0000004-220629164930563-oozie-sun_-W

    1. Job ID : 0000004-220629164930563-oozie-sun_-W
    2. ------------------------------------------------------------------------------------------------------------------------------------
    3. Workflow Name : shell-wf
    4. App Path : hdfs://localhost:9000/user/sun_xo/oozie/apps/shell
    5. Status : SUCCEEDED
    6. Run : 0
    7. User : sun_xo
    8. Group : -
    9. Created : 2022-06-29 09:22 GMT
    10. Started : 2022-06-29 09:22 GMT
    11. Last Modified : 2022-06-29 09:22 GMT
    12. Ended : 2022-06-29 09:22 GMT
    13. CoordAction ID: -
    14. Actions
    15. ------------------------------------------------------------------------------------------------------------------------------------
    16. ID Status Ext ID Ext Status Err Code
    17. ------------------------------------------------------------------------------------------------------------------------------------
    18. 0000004-220629164930563-oozie-sun_-W@:start: OK - OK -
    19. ------------------------------------------------------------------------------------------------------------------------------------
    20. 0000004-220629164930563-oozie-sun_-W@shell-node OK application_1656492227290_0007SUCCEEDED -
    21. ------------------------------------------------------------------------------------------------------------------------------------
    22. 0000004-220629164930563-oozie-sun_-W@check-output OK - end -
    23. ------------------------------------------------------------------------------------------------------------------------------------
    24. 0000004-220629164930563-oozie-sun_-W@end OK - OK -
    25. ------------------------------------------------------------------------------------------------------------------------------------
  • 相关阅读:
    【从0-1成为架构师】性能优化的手段
    MySQL中有哪些约束?(实例验证)
    报错IDEA Terminated with exit code 1
    Java设计模式之备忘录模式
    C++面向对象(一)
    【Rust日报】2023-11-08 RustyVault -- 基于 rust 的现代秘密管理系统
    C++ Qt开发:CheckBox多选框组件
    watch 和 watchEffect
    lattice crosslink开发板mipi核心板csi测试dsi屏lif md6000 fpga
    python实现综合评价模型TOPSIS
  • 原文地址:https://blog.csdn.net/sun_xo/article/details/125527175