ITPub博客

首页 > 大数据 > Hadoop > oozie入门

oozie入门

Hadoop 作者:破棉袄 时间:2014-08-18 12:00:04 0 删除 编辑

 

oozie概述:

oozie是基于hadoop的调度器,以xml的形式写调度流程,可以调度mr,pig,hive,shell,jar等等。

主要的功能有

Workflow: 顺序执行流程节点,支持fork(分支多个节点),join(合并多个节点为一个)

Coordinator,定时触发workflow

Bundle Job,绑定多个coordinator

 

oozie格式:

写一个oozie,有两个是必要的:job.properties 和 workflow.xml(coordinator.xml,bundle.xml)

一、job.properties里定义环境变量

nameNode hdfs://xxx5:8020 hdfs地址
jobTracker xxx5:8034 jobTracker地址
queueName default oozie队列
examplesRoot examples 全局目录
oozie.usr.system.libpath true 是否加载用户lib库
oozie.libpath share/lib/user 用户lib库
oozie.wf.appication.path ${nameNode}/user/${user.name}/... oozie流程所在hdfs地址

注意:

workflow:oozie.wf.application.path

coordinator:oozie.coord.application.path

bundle:oozie.bundle.application.path

 

二、XML

 1.workflow:

 

Xml代码 复制代码 收藏代码
  1. <workflow-app xmlns="uri:oozie:workflow:0.2" name="wf-example1">  
  2.   <start to="pig-node">  
  3.   <action name="pig-node">  
  4.       <pig>  
  5.            <job-tracker>${jobTracker}job-tracker>  
  6.            <name-node>${nameNode}name-node>  
  7.            <prepare>  
  8.               <delete path="hdfs://xxx5/user/hadoop/appresult" />  
  9.            prepare>  
  10.            <configuration>  
  11.              <property>  
  12.                   <name>mapred.job.queue.namename>  
  13.                    <value>defaultvalue>  
  14.               <property>  
  15.              <property>  
  16.                   <name>mapred.compress.map.outputname>  
  17.                    <value>truevalue>  
  18.               <property>  
  19.              <property>  
  20.                   <name>mapreduce.fileoutputcommitter.marksuccessfuljobsname>  
  21.                    <value>falsevalue>  
  22.               <property>  
  23.            configuration>  
  24.             <script>test.pigscript>  
  25.             <param>filepath=${filpath}param>  
  26.       pig>  
  27.        <ok to="end">  
  28.         <error to="fail">  
  29.   action>  
  30.   <kill name="fail">  
  31.        <message>  
  32.                    Map/Reduce failed, error               message[${wf:errorMessage(wf:lastErrorNode())}]  
  33.          message>  
  34.     kill>  
  35.    <end name="end"/>  
  36. workflow-app>  
 

 

2.coordinator

 

Xml代码 复制代码 收藏代码
  1. <coordinator-app name="cron-coord" frequence="${coord:hours(6)}" start="${start}" end="${end}"  
  2. timezoe="UTC" xmlns="uri:oozie:coordinator:0.2">  
  3. <action>  
  4. <workflow>  
  5.    <app-path>${nameNode}/user/{$coord:user()}/${examplesRoot}/wpathapp-path>  
  6.   <configuration>  
  7.            <property>  
  8.            <name>jobTrackername>  
  9.            <value>${jobTracker}value>  
  10.            property>  
  11.            <property>  
  12.            <name>nameNodename>  
  13.            <value>${nameNode}value>  
  14.            property>  
  15.            <property>  
  16.            <name>queueNamename>  
  17.            <value>${queueName}value>  
  18.        property>  
  19.   configuration>  
  20. workflow>  
  21. action>  

 注意:coordinator设置的UTC,比北京时间晚8个小时,所以你要是把期望执行时间减8小时

 

3.bundle

 

Java代码 复制代码 收藏代码
  1. 'APPNAME' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:bundle:0.1'>   
  2.     
  3.        ${kickOffTime}  
  4.     
  5.    'coordJobFromBundle1' >  
  6.        ${appPath}  
  7.          
  8.            
  9.               startTime1  
  10.               ${START_TIME}  
  11.             
  12.            
  13.               endTime1  
  14.               ${END_TIME}  
  15.             
  16.         
  17.      
  18.    'coordJobFromBundle2' >  
  19.        ${appPath2}  
  20.          
  21.            
  22.               startTime2  
  23.               ${START_TIME2}  
  24.             
  25.            
  26.               endTime2  
  27.               ${END_TIME2}  
  28.             
  29.         
  30.      
  31.   

 

oozie运行

启动任务:

Java代码 复制代码 收藏代码
  1. oozie job -oozie http://xxx5:11000/oozie -config job.properties -run  

 

停止任务:

oozie job -oozie http://localhost:8080/oozie -kill 14-20090525161321-oozie-joe

注意:在停止任务的时候,有的时候会出现全线问题,需要修改oozie-site.xml文件

hadoop.proxyuser.oozie.groups *

hadoop.proxyuser.oozie.hosts *

oozie.server.ProxyUserServer.proxyuser.hadoop.hosts *

oozie.server.ProxyUserServer.proxyuser.hadoop.groups *

原文:http://blackproof.iteye.com/blog/1928122

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29754888/viewspace-1253075/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Mapreduces溢写
下一篇: oozie java api
请登录后发表评论 登录
全部评论

注册时间:2014-07-16

  • 博文量
    180
  • 访问量
    1158168