oozie的简单案例

1、fs的action:
================job.properties的内容如下:
nameNode=hdfs://hadoop007:9000
jobTracker=hadoop007:8032
queueName=default
examplesRoot=fs


oozie.wf.application.path=${nameNode}/user/${user.name}/workflows/${examplesRoot}/workflow.xml


======================workflow.xml的内容如下:
<workflow-app name='fs-wf1' xmlns="uri:oozie:workflow:0.2">
 <start to="fs-delete"/>
 <action name="fs-delete">
  <fs>
    <delete path="${nameNode}/oozie.sql" />
    <delete path="${nameNode}/bin" />
  </fs>
  <ok to="fs-mkdir" />
  <error to="fail" />
</action>




 <action name="fs-mkdir">
  <fs>
   <mkdir path="${nameNode}/beicai" />
 </fs>
 <ok to="fs-move" />
 <error to="fail" />
 </action>


 <action name="fs-move">
  <fs>
   <move source="${nameNode}/123" target="${nameNode}/out/"/>
  </fs>
  <ok to="end" />
  <error to="fail" />
 </action>


 <kill name="fail">
  <message>script failed, error message:${wf:errorMessage(wf:lastErrorNode())}</message>
 </kill>


 <end name="end"/>
</workflow-app>


提交并运行作业:oozie job -oozie http://hadoop007:11000/oozie -config ./job.properties -run


2、fs的选择action:
================job.properties的内容如下:
nameNode=hdfs://hadoop007:9000
jobTracker=hadoop007:8032
queueName=default
examplesRoot=fs2


oozie.wf.application.path=${nameNode}/user/${user.name}/workflows/${examplesRoot}/workflow.xml


======================workflow.xml的内容如下:
<workflow-app name='fs-wf1' xmlns="uri:oozie:workflow:0.3">


 <start to="decision" />
 <decision name="decision">
  <switch>
   <case to="fs-delete">${fs:exists("/beicai/123")}</case>
   <default to="end"></default>
  </switch>
 </decision>
 <action name="fs-delete">
  <fs>
   <delete path="${nameNode}/beicai/123" />
  </fs>
  <ok to="end" />
  <error to="fail" />
 </action>


 <kill name="fail">
  <message>script failed, error message:${wf:errorMessage(wf:lastErrorNode())}</message>
 </kill>


 <end name="end"/>
</workflow-app>


提交并运行作业:oozie job -oozie http://hadoop007:11000/oozie -config ./job.properties -run




3、shell的action:
================job.properties的内容如下:
nameNode=hdfs://hadoop007:9000
jobTracker=hadoop007:8032
queueName=default
examplesRoot=shell
exec=script.sh


oozie.wf.application.path=${nameNode}/user/${user.name}/workflows/${examplesRoot}/workflow.xml


======================workflow.xml的内容如下:
<workflow-app name="shell-wf" xmlns="uri:oozie:workflow:0.3" >
 <start to="shell" />
 <action name="shell">
  <shell xmlns="uri:oozie:shell-action:0.1">
   <job-tracker>${jobTracker}</job-tracker>
   <name-node>${nameNode}</name-node>
   <exec>${exec}</exec>
   <file>${exec}#${exec}</file>
  </shell>
  <ok to="end" />
  <error to="fail" />


 </action>


 <kill name="fail">
  <message>script failed, error message:${wf:errorMessage(wf:lastErrorNode())}</message>
 </kill>


 <end name="end"/>
</workflow-app>


提交并运行作业:oozie job -oozie http://hadoop007:11000/oozie -config ./job.properties -run


4、hive的action:
================job.properties的内容如下:
nameNode=hdfs://hadoop007:9000
jobTracker=hadoop007:8032
queueName=default
examplesRoot=hive


oozie.use.system.libpath=true
oozie.wf.application.path=${nameNode}/user/${user.name}/workflows/${examplesRoot}/workflow.xml


======================workflow.xml的内容如下:
<workflow-app name="hive-wf" xmlns="uri:oozie:workflow:0.3" >
 <start to="myfirstjob" />


 <action name="myfirstjob">
  <hive xmlns="uri:oozie:hive-action:0.2">
   <job-tracker>${jobTracker}</job-tracker>
   <name-node>${nameNode}</name-node>
   <configuration>
    <property>
     <name>oozie.hive.defaults</name>
     <value>hive-site.xml</value>
    </property>
   <!--<property>  
     <name></name>
     <value>hive-site.xml</value>
    </property>-->
   <property>
     <name>hive.metastore.local</name>
     <value>false</value>
   </property>
   <property>
     <name>hive.metastore.uris</name>
     <value>thrift://192.168.216.7:9083</value>
   </property>
   <property>
     <name>hive.metastore.warehouse.dir</name>
     <value>/user/hive/warehouse</value>
   </property>
   </configuration>
   <script>myfirst.sql</script>
  </hive>
  <ok to="end" />
  <error to="fail" />
 </action>


 <kill name="fail">
  <message>script failed, error message:${wf:errorMessage(wf:lastErrorNode())}</message>
 </kill>


 <end name="end"/>
</workflow-app>


myfirst.sql 文件内容如下:
load data inpath "/data" into table ooziehivetable;




提交并运行作业:oozie job -oozie http://hadoop007:11000/oozie -config ./job.properties -run


5、mapreduce的action:(执行的mr的job包需要放在当前目录的lib下面)
================job.properties的内容如下:
nameNode=hdfs://hadoop007:9000
jobTracker=hadoop007:8032
queueName=default
examplesRoot=map-reduce


oozie.wf.application.path=${nameNode}/user/${user.name}/workflows/${examplesRoot}/workflow.xml




======================workflow.xml的内容如下:
<workflow-app name="mapreduce-wf" xmlns="uri:oozie:workflow:0.3" >
 <start to="grep" />
 
 <action name="grep">
  <map-reduce>
   <job-tracker>${jobTracker}</job-tracker>
   <name-node>${nameNode}</name-node>
   <prepare>
    <delete path="/out/oozie/00"></delete>
    <delete path="/out/oozie/01" />
   </prepare>
   <configuration>
    <property>
     <name>mapred.mapper.new-api</name>
     <value>true</value>
    </property>
   <property>  
     <name>mapred.reducer.new-api</name>
     <value>true</value>
   </property>
   <property>
     <name>mapreduce.job.map.class</name>
     <value>edu.beicai.mr.test.Grep$MyMapper</value>
   </property>
   <property>
     <name>mapreduce.input.fileinputformat.inputdir</name>
     <value>/user/hadoop/workflows/map-reduce/data</value>
   </property>
   <property>
     <name>mapreduce.job.output.key.class</name>
     <value>org.apache.hadoop.io.Text</value>
   </property>
   <property>
    <name>mapreduce.job.output.value.class</name>
    <value>org.apache.hadoop.io.Text</value>
   </property>
   <property>
    <name>mapreduce.output.fileoutputformat.outputdir</name>
    <value>/out/oozie/00</value>
   </property>
   <property>
    <name>mapreduce.job.acl-view-job</name>
    <value>*</value>
   </property>
   <property>
    <name>oozie.launcher.mapreduce.job.acl-view-job</name>
    <value>*</value>
   </property>
   </configuration>
  </map-reduce>
  <ok to="wordcount" />
  <error to="fail" />
 </action> 
 
 
  <action name="wordcount">
  <map-reduce>
   <job-tracker>${jobTracker}</job-tracker>
   <name-node>${nameNode}</name-node>
   <prepare>
    <delete path="/out/oozie/01" />
   </prepare>
   <configuration>
    <property>
     <name>mapred.mapper.new-api</name>
     <value>true</value>
    </property>
   <property>  
     <name>mapred.reducer.new-api</name>
     <value>true</value>
   </property>
   <property>
     <name>mapreduce.job.map.class</name>
     <value>edu.beicai.mr.test.WordCount$MyMapper</value>
   </property>
   <property>
<name>mapreduce.job.reduce.class</name>
<value>edu.beicai.mr.test.WordCount$MyReducer</value>
   </property>
   <property>
     <name>mapreduce.input.fileinputformat.inputdir</name>
     <value>/out/oozie/00</value>
   </property>
   <property>
     <name>mapreduce.job.output.key.class</name>
     <value>org.apache.hadoop.io.Text</value>
   </property>
   <property>
    <name>mapreduce.job.output.value.class</name>
    <value>org.apache.hadoop.io.Text</value>
   </property>
   <property>
    <name>mapreduce.output.fileoutputformat.outputdir</name>
    <value>/out/oozie/01</value>
   </property>
   <property>
    <name>mapreduce.job.acl-view-job</name>
    <value>*</value>
   </property>
   <property>
    <name>oozie.launcher.mapreduce.job.acl-view-job</name>
    <value>*</value>
   </property>
   </configuration>
  </map-reduce>
  <ok to="end" />
  <error to="fail" />
 </action> 


 <kill name="fail">
  <message>script failed, error message:${wf:errorMessage(wf:lastErrorNode())}</message>
 </kill>


 <end name="end"/>
</workflow-app>


提交并运行作业:oozie job -oozie http://hadoop007:11000/oozie -config ./job.properties -run


6、coordinator的action:
================job.properties的内容如下:
nameNode=hdfs://hadoop007:9000
jobTracker=hadoop007:8032
queueName=default
examplesRoot=coordinator


oozie.service.coord.check.maximum.frequency=false
oozie.coord.application.path=${nameNode}/user/${user.name}/workflows/${examplesRoot}
start=2017-03-14T22:30+0800
end=2017-03-14T22:40+0800
workflowAppUri=${oozie.coord.application.path}


======================workflow.xml的内容如下:(空的wf)
<workflow-app name='coord' xmlns="uri:oozie:workflow:0.3">
 <start to="end"/>


 <end name="end"/>
</workflow-app>




======================coordinator.xml的内容如下:
<coordinator-app name="cron-coord" frequency="${coord:minutes(2)}" start="${start}" end="${end}" timezone="UTC" xmlns="uri:oozie:coordinator:0.2">
<action>
<workflow>
<app-path>${workflowAppUri}</app-path>
<configuration>
<property>
<name>jobTracker</name>
<value>${jobTracker}</value>
</property>
<property>
<name>nameNode</name>
<value>${nameNode}</value>
</property>
<property>
<name>queueName</name>
<value>${queueName}</value>
</property>
</configuration>
</workflow>
</action>
</coordinator-app>


提交并运行作业:oozie job -oozie http://hadoop007:11000/oozie -config ./job.properties -run
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大数据东哥(Aidon)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值