本workflow位於oozie目錄下新創建的一個oozie-apps文件夾下的mr-wc-wf文件夾中。
mr-wc-wf:
1、job.properties
2、lib文件夾(其中包含了一個wordcount程序的jar包)
3、workflow.xml
將整個oozie-apps文件夾上傳到hdfs的對應用戶目錄下
然後運行程序
bin/oozie job -config oozie-apps/mr-wc-wf/job.properties -run
job.properies:
nameNode=hdfs://BPF:9000
jobTracker=BPF:8032
queueName=default
oozie-appsRoot=user/bpf/oozie-apps
DataRoot=user/bpf/oozie/datas
oozie.wf.application.path=${nameNode}/${oozie-appsRoot}/mr-wc-wf/workflow.xml
inputDir=mr-wc-wf/input
outputDir=mr-wc-wf/output
workflow.xml:
<workflow-app xmlns="uri:oozie:workflow:0.5" name="map-wc-wf">
<start to="mr-node-wc"/>
<action name="mr-node-wc">
<map-reduce>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<prepare>
<delete path="${nameNode}/${DataRoot}/${outputDir}"/>
</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.queuename</name>
<value>${queueName}</value>
</property>
<property>
<name>mapreduce.job.map.class</name>
<value>com.bpf.hadoop.WordCount$TokenizerMapper</value>
</property>
<property>
<name>mapreduce.job.reduce.class</name>
<value>com.bpf.hadoop.WordCount$IntSumReducer</value>
</property>
<property>
<name>mapreduce.map.output.key.class</name>
<value>org.apache.hadoop.io.Text</value>
</property>
<property>
<name>mapreduce.map.output.value.class</name>
<value>org.apache.hadoop.io.IntWritable</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.IntWritable</value>
</property>
<property>
<name>mapreduce.input.fileinputformat.inputdir</name>
<value>${nameNode}/${DataRoot}/${inputDir}</value>
</property>
<property>
<name>mapreduce.output.fileoutputformat.outputdir</name>
<value>${nameNode}/${DataRoot}/${outputDir}</value>
</property>
</configuration>
</map-reduce>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>