zoukankan      html  css  js  c++  java
  • Oozie 实战之 shell

    说明:使用 shell action 执行 shell 脚本 hive-select-test.sh 来通过已经配置好的 Hive -f 来执行 HQL 查询脚本文件 select.sql

    1.创建脚本文件 hive-select-test.sh

    #!/bin/sh
    /opt/cdh5.3.6/hive-1.1.0-cdh5.12.0/bin/hive -f select.sql
    

    2.创建 HQL 文件 select.sql

    insert overwrite directory '/user/cen/oozie-apps/shell-hive-select/output/' select count(1)  cnt from default.test; 
    

    3.修改 job.properties 文件

    nameNode=hdfs://cen-ubuntu.cenzhongman.com:8020
    jobTracker=localhost:8032
    queueName=default
    oozieAppsRoot=oozie-apps
    
    oozie.wf.application.path=${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/
    EXEC=hive-select-test.sh
    script=select.sql
    

    4.修改 workflow.xml 文件

    <workflow-app xmlns="uri:oozie:workflow:0.5" 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>
                <file>${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/${EXEC}#${EXEC}</file>
                <file>${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/${script}#${script}</file>
            </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>
    

    注意事项

    • workflow 版本0,5 sqoop action 版本0.2
    • 使用的是新版本的API,但旧版本依旧支持使用(可以不用改)
    • 关于file作用和配置,下文会说明

    5.上传文件到HDFS文件系统

    6.执行程序

    export OOZIE_URL=http://cen-ubuntu:11000/oozie/
    bin/oozie job --config oozie-apps/shell-hive-select/job.properties -run
  • 相关阅读:
    驱动表
    将索引移动到别的表空间
    log file sync, log file parallell write
    Full Hint
    4wpa_supplicant适配层 详解
    wifi 驱动 进阶11
    wifi 驱动 进阶11
    基于linux2.6.38.8内核的SDIO/wifi驱动分析
    6wpa_supplicant无线网络配置
    2系统启动后的 wifi加载 过程图解
  • 原文地址:https://www.cnblogs.com/cenzhongman/p/7253157.html
Copyright © 2011-2022 走看看