2016-01-12 99 views

回答

0

在Oozie中,您可以在同一個工作流程中調用另一個操作來調用Muiltiple hadoop作業,只有點需要檢查它應該用不同的操作名稱調用不同的操作。

下面的例子可以幫助

例如:去通過Oozie的,以調用兩個shell腳本,它會做的 1腳本copy.sh將cluster1中執行DistCp使用行動Cluster2中 第二個腳本將執行下載從cluster2複製轉儲到本地位置。 所以工作流會像:

<workflow-app xmlns='uri:oozie:workflow:0.2' name='testworkflowaction'> 
    <start to='UserVectorUpload'/> 
    <action name="shellAction_1"> 
     <shell xmlns="uri:oozie:shell-action:0.1"> 
      <job-tracker>${jobTracker}</job-tracker> 
      <name-node>${nameNode}</name-node> 
      <configuration> 
       <property> 
        <name>oozie.launcher.mapred.job.queue.name</name> 
        <value>default</value> 
       </property> 
      </configuration> 
      <exec>scipt_copy.sh</exec> 
         <file>hdfs://cluster2:8020/localtion_of_script_in_cluster/scipt_copy.sh</file> 
      <capture-output/> 
     </shell> 
     <ok to="shellAction_2"/> 
     <error to="killAction"/> 
    </action> 
     <kill name="killAction"> 
       <message>Shell Action Failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> 
    </kill> 
    <action name="shellAction_2"> 
     <shell xmlns="uri:oozie:shell-action:0.1"> 
      <job-tracker>${jobTracker}</job-tracker> 
      <name-node>${nameNode}</name-node> 
      <configuration> 
       <property> 
        <name>oozie.launcher.mapred.job.queue.name</name> 
        <value>default</value> 
       </property> 
      </configuration> 
      <exec>scipt_download.sh</exec> 
         <file>hdfs://cluster2:8020/localtion_of_script_in_cluster/scipt_download.sh</file> 
      <capture-output/> 
     </shell> 
     <ok to="end"/> 
     <error to="killAction"/> 
    </action> 
     <kill name="killAction"> 
       <message>Shell Action Failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> 
    </kill> 

所以通過上面的例子中第一個動作是從clustet1執行script_copy.sh使用DistCp使用到Cluster2中,一旦DistCp使用完成後它將從cluste2下載同當地位置使用得到copyToLocal函數。

您可以使用的另一個備用選項將單個腳本中的操作和單個操作中的所有操作組合在一起,儘管此步驟對於腳本過程而言並非有用,而且非常複雜。