【问题标题】:automate the shell script using oozie使用 oozie 自动化 shell 脚本
【发布时间】:2018-04-16 07:48:49
【问题描述】:

我必须一次又一次地对来自水槽的传入数据运行相同的脚本,所以我想自动化它。那么如何在一定的时间间隔内使用 Oozie 自动化一个 pig 脚本呢?

【问题讨论】:

标签: hadoop apache-pig oozie


【解决方案1】:

无耻抄袭https://github.com/YahooArchive/oozie/wiki/Oozie-Coord-Use-Cases

当数据文件可用时触发协调器作业 您可以为 Coordinator Job 定义输入数据依赖关系。在创建输入文件之前,您的作业不会运行。

eg. hdfs://localhost:9000/tmp/revenue_feed/2010/06/01/03/trigger.dat
$ cat coordinator.xml
<coordinator-app name="MY_APP" frequency="1440" start="2009-02-01T00:00Z" end="2009-02-07T00:00Z" timezone="UTC" xmlns="uri:oozie:coordinator:0.1">
   <datasets>
      <dataset name="input1" frequency="60" initial-instance="2009-01-01T00:00Z" timezone="UTC">
         <uri-template>hdfs://localhost:9000/tmp/revenue_feed/${YEAR}/${MONTH}/${DAY}/${HOUR}</uri-template>
         <done-flag>trigger.dat</done-flag>
      </dataset>
   </datasets>
   <input-events>
      <data-in name="coordInput1" dataset="input1">
          <start-instance>${coord:current(-23)}</start-instance>
          <end-instance>${coord:current(0)}</end-instance>
      </data-in>
   </input-events>
   <action>
      <workflow>
         <app-path>hdfs://localhost:9000/tmp/workflows</app-path>
      </workflow>
   </action>     
</coordinator-app>

【讨论】:

  • ${coord:current(-23)}${coord:current(0)} . coord:current(-23) 和 coord:current(0) 是什么?
  • 这是它运行的时间段,在这种情况下是过去 24 小时。
【解决方案2】:

有两种方法可以实现这一点

  1. 您可以创建一个带有必要操作的 Oozie 工作流,并编写一个 shellscript 来触发 Oozie,并使用 cron 作业对其进行调度

设置 cron 作业的命令:

crontab -e

编写 shell 脚本的好处是,您可以在某些作业失败时设置失败电子邮件通知。

  1. 编写带有开始和结束时间的 Oozie 作业

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-12
    • 2014-08-23
    • 1970-01-01
    • 2015-03-18
    相关资源
    最近更新 更多