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
  • 相关阅读:
    mysql增加字段,修改字段,增加索引等语句
    php获取post参数的几种方式
    微信小程序开发注意事项
    jQuery的deferred对象详解
    jquery.pagination.js的使用
    js实现一键复制
    PHP读取文件内容的五种方式
    3.3 模块的搜索路径
    3.2 py文件的两种功能
    3.1 模块的定义与分类,import,from...import
  • 原文地址:https://www.cnblogs.com/cenzhongman/p/7253157.html
Copyright © 2011-2022 走看看