oozie調度系統調研
1. 關於oozie的簡單說明
-
oozie應用程序目錄結構說明:
一個完整的oozie應用程序一般情況下至少包含三個文件及目錄:job.properties、workflow.xml、lib(lib表示為用來存放程序運行需要的jar包,非必需)
-
flow nodes的六種類型:
start, end, decision, fork, join, kill
-
action-node的部分類型:
Hadoop map-reduce, Hadoop file system, Pig, SSH, HTTP, eMail and Oozie sub-workflow,
Oozie可以自定義擴展任務類型。
2. Oozie簡介
-
WorkFlow:工作流,控制工作流的開始和結束過程,以及工作流Job的執行路徑,並提供一種機制來控制工作流執行路徑(比如:Decision、Fork以及Join節點等)
-
Coordinator:調度器,多個WorkFlow可以組成一個Coordinator,可以把前幾個WorkFlow的輸出作為后一個WorkFlow的輸入,當然也可以定義WorkFlow的觸發條件,來做定時觸發.
-
Bundle:控制一個或多個Coordinator應用
3. 一個標准的工作流的示例
hPDL流程的定義:
<workflow-app name='wordcount-wf' xmlns="uri:oozie:workflow:0.1">
<start to='wordcount'/>
<action name='wordcount'>
<map-reduce>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.mapper.class</name>
<value>org.myorg.WordCount.Map</value>
</property>
<property>
<name>mapred.reducer.class</name>
<value>org.myorg.WordCount.Reduce</value>
</property>
<property>
<name>mapred.input.dir</name>
<value>${inputDir}</value>
</property>
<property>
<name>mapred.output.dir</name>
<value>${outputDir}</value>
</property>
</configuration>
</map-reduce>
<ok to='end'/>
<error to='end'/>
</action>
<kill name='kill'>
<message>Something went wrong: ${wf:errorCode('wordcount')}</message>
</kill/>
<end name='end'/>
</workflow-app>
4.在hue中創建一個workflow。
在hue中可以通過拖拽的方式進行workflow.xml的編輯:
hue的任務管理頁面:
hue編輯的workflow.xml保存在hdf上的/user/oozie/workspaces/目錄下:
/user/oozie/workspaces/hue-oozie-1476263861.83
[fuxin.zhao@db-hadoop-client02 ~]$ hadoop fs -ls /user/oozie/workspaces/hue-oozie-1476263861.83
Found 3 items
-rw-r--r-- 3 hue hadoop 114 2016-10-12 17:33 /user/oozie/workspaces/hue-oozie-1476263861.83/job.properties
drwxr-xr-x - hue hadoop 0 2016-10-12 17:17 /user/oozie/workspaces/hue-oozie-1476263861.83/lib
-rw-r--r-- 3 hue hadoop 1277 2016-10-12 17:33 /user/oozie/workspaces/hue-oozie-1476263861.83/workflow.xml
自動生成的workflow文件內容如下:workflow的大體流程已經自動生成了,自己可以根據需要進行修改。
<workflow-app name="job-test-workflow" xmlns="uri:oozie:workflow:0.5">
<start to="shell-f60d"/>
<kill name="Kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="shell-f60d">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>/user/hue/aa.sh</exec>
<argument>args1</argument>
<argument>args2</argument>
<argument>args2</argument>
<file>/user/hue/avro-1.7.4.jar#avro-1.7.4.jar</file>
<capture-output/>
</shell>
<ok to="shell-dfe8"/>
<error to="Kill"/>
</action>
<action name="shell-dfe8">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>/user/hue/aa.sh</exec>
<capture-output/>
</shell>
<ok to="kill-ece6"/>
<error to="Kill"/>
</action>
<kill name="kill-ece6">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="End"/>
</workflow-app>
5.提交oozie命令
1 .提交oozie任務
oozie job -oozie http://localhost:11000/oozie/ -config /root/tvreport-workflow/tvreport-daily-wf/job.properties -run
2 .提交kill 任務
oozie job -oozie http://localhost:11000/oozie -kill 0031861-140812111151262-oozie-root-W
3.查看job的日志信息
bin/oozie job -oozie http://hadoop-1:11000/oozie -log 0000001-160702224410648-oozie-beif-W
》》》未完待續。