乐趣区

oozie创建工作流手动配置和使用Hue配置

oozie 创建工作流

工作流的执行命令参考博客:https://www.jianshu.com/p/6cb3a4b78556,也可以键入 oozie help 查看帮助

手动配置 oozie 的 workflow

job.properties 文件,存放 workflow.xml 文件可能用到的一些参数
job.properties

# 注意变量名不要包含特殊字符,否则在 spark 中会出现无法解析变量名的问题

nameNode=hdfs://txz-data0:9820
resourceManager=txz-data0:8032
oozie.use.system.libpath=true
oozie.libpath=${nameNode}/share/lib/spark2/jars/,${nameNode}/share/lib/spark2/python/lib/,${nameNode}/share/lib/spark2/hive-site.xml
oozie.wf.application.path=${nameNode}/workflow/data-factory/download_report_voice_and_upload/Workflow
oozie.action.sharelib.for.spark=spark2

archive=${nameNode}/envs/py3.tar.gz#py

# 如果 dryrun 为 true,表示只是测试当前的 workflow,并不具体记录相应 job
dryrun=false

sparkMaster=yarn-cluster
sparkMode=cluster
scriptRoot=/workflow/data-factory/download_report_voice_and_upload/Python
sparkScriptBasename=download_parquet_from_data0_upload_online.py
sparkScript=${scriptRoot}/${sparkScriptBasename}
pysparkPath=py/py3/bin/python3

workflow.xml 文件

<!--
    这是为 oozie 的 workflow 提供参数,里面用到的变量默认来自 job.properties 文件
-->

<workflow-app xmlns='uri:oozie:workflow:1.0' name='download_parquet_from_data0_upload_online'>

    <global>
        <resource-manager>${resourceManager}</resource-manager>
        <name-node>${nameNode}</name-node>
    </global>

    <start to='spark-node' />

    <action name='spark-node'>
        <spark xmlns="uri:oozie:spark-action:1.0">
            <master>${sparkMaster}</master>
            <mode>${sparkMode}</mode>
            <name>report_voice_download_pyspark</name>
            <jar>${sparkScriptBasename}</jar>
            <spark-opts>
                --conf spark.yarn.appMasterEnv.PYSPARK_PYTHON=${pysparkPath}
            </spark-opts>
            <file>${sparkScript}#${sparkScriptBasename}</file>
            <archive>${archive}</archive>
        </spark>

        <ok to="end" />
        <error to="fail" />
    </action>

    <kill name="fail">
        <message>
            Workflow failed, error
            message[${wf:errorMessage(wf:lastErrorNode())}]
        </message>
    </kill>
    <end name='end' />
</workflow-app>

将这两个文件放在本地磁盘上面,例如放在文件夹 /home/workflow/

运行命令 oozie job -oozie http://txz-data0:11000/oozie -config /home/workflow/job.properties -run 即可运行这个 workflow

这样手写配置的话,在 Hue 上面是不可见的,所以后面都是在 Hue 上面配置 workflow,然后再配置 Schedule。具体配置见博客 https://blog.csdn.net/qq_22918243/article/details/89204111

退出移动版