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
================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