Skip to content

Commit 741a8a8

Browse files
committed
add blogs
1 parent 5aa9853 commit 741a8a8

File tree

3 files changed

+230
-2
lines changed

3 files changed

+230
-2
lines changed
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
---
2+
layout: post
3+
title: "HOW TO USE OOIZE"
4+
subtitle: "大数据调度框架 ooize 的基本使用以及图解"
5+
date: 2010-08-25
6+
author: "LSG"
7+
header-img: "img/ooize.png"
8+
catalog: true
9+
tags:
10+
- hadoop
11+
- ooize
12+
- spark
13+
- 调度框架
14+
---
15+
16+
> **Oozie是大数据四大协作框架之一——任务调度框架,另外三个分别为数据转换工具Sqoop,文件收集库框架Flume,大数据WEB工具Hue。**
17+
18+
### 一. 安装和配置
19+
配置邮件:
20+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578828737388-2c0995f5-4c4f-45b4-9ef5-0b223b56cc0b.png#align=left&display=inline&height=1006&name=image.png&originHeight=1006&originWidth=1499&size=148673&status=done&style=none&width=1499)
21+
22+
### 二 .使用和常用命令
23+
#### 2.1 验证正确性
24+
25+
1. 验证wokflow.xml :
26+
`oozie validate /appcom/apps/hduser0401/mbl_webtrends/workflow.xml`
27+
28+
1. 查看oozie服务状态:
29+
`oozie admin -oozie http://localhost:11000/oozie -status`
30+
31+
#### 2.2 执行,准备,提交,直接运行任务
32+
33+
1. 提交作业,作业进入PREP状态 submit
34+
`oozie job -oozie http://localhost:11000/oozie -config job.properties -submit`
35+
命令行出现: `job: jobID`
36+
37+
1. 执行已提交的作业 start
38+
`oozie job -ooziehttp://localhost:11000/oozie -start jobID`
39+
40+
1. 直接运行作业 run ->一般使用该方式
41+
`oozie job -oozie http://localhost:11000/oozie -config job.properties -run`
42+
43+
1. 挂起和恢复
44+
挂起->`oozie job -suspend 0000004-180119141609585-oozie-hado-C`
45+
恢复->`oozie job -resume 0000004-180119141609585-oozie-hado-C`
46+
47+
1. 杀死作业
48+
`oozie job -oozie http://localhost:11000/oozie -kill 14-20090525161321-oozie-joe`
49+
50+
1. 改变作业参数,不能修改killed状态的作业
51+
`oozie job -oozie http://localhost:11000/oozie -change 14-20090525161321-oozie-joe -value endtime=2011-12-01T05:00Z;concurrency=100;2011-10-01T05:00Z`
52+
53+
1. 重新运行作业
54+
`oozie job -rerun 0006360-160701092146726-oozie-hado-C -refresh -action 477-479`
55+
`oozie job -rerun 0006360-160701092146726-oozie-hado-C -D oozie.wf.rerun.failnodes=false`
56+
57+
1. 检查作业状态
58+
`oozie job -oozie http://localhost:11000/oozie -info 14-20090525161321-oozie-joe`
59+
60+
1. 查看日志
61+
`oozie job -oozie http://localhost:11000/oozie -log 14-20090525161321-oozie-joe`
62+
63+
1. 提交pig作业
64+
`oozie pig -oozie http://localhost:11000/oozie -file pigScriptFile -config job.properties -X -param_file params`
65+
66+
1. 提交MR作业
67+
`oozie mapreduce -oozie http://localhost:11000/oozie -config job.properties`
68+
69+
1. 查看共享库 :
70+
`oozie admin -shareliblist sqoop`
71+
72+
1. 动态更新共享库 :
73+
`oozie admin -sharelibupdate`
74+
75+
### 三. wookflow语法
76+
77+
```xml
78+
79+
<workflow-app xmlns="uri:oozie:workflow:0.2" name="Test">
80+
<start to="GoodsNameGroup"/>
81+
<action name="GoodsNameGroup">
82+
<spark xmlns="uri:oozie:spark-action:0.2">
83+
<job-tracker>${jobTracker}</job-tracker>
84+
<name-node>${nameNode}</name-node>
85+
<job-xml>${workflowAppUri}/hive-site.xml</job-xml>
86+
<configuration>
87+
<property>
88+
<name>oozie.action.sharelib.for.spark</name>
89+
<value>spark2 </value>
90+
</property>
91+
<property>
92+
<name>oozie.use.system.libpath</name>
93+
<value>true</value>
94+
</property>
95+
<property>
96+
<name>mapred.job.queue.name</name>
97+
<value>${queueName}</value>
98+
</property>
99+
<property>
100+
<name>tez.queue.name</name>
101+
<value>${queueName}</value>
102+
</property>
103+
104+
</configuration>
105+
<master>yarn-cluster</master>
106+
<mode>cluster</mode>
107+
<name>GoodsNameGroup</name>
108+
<class>com.wangdian.spark.tasks.main.clear.test.GoodsNameGroup</class>
109+
<jar>${jarPath}</jar>
110+
<spark-opts>--executor-cores 1 --executor-memory 3584M --num-executors 20 --queue ${queueName}</spark-opts>
111+
</spark>
112+
<ok to="end"/>
113+
<error to="an-email"/>
114+
</action>
115+
<action name="an-email">
116+
<email xmlns="uri:oozie:email-action:0.1">
117+
118+
<subject>Email notifications for ${wf:id()} spark-test</subject>
119+
<body>The wf ${wf:id()} failed completed.</body>
120+
</email>
121+
<ok to="kill"/>
122+
<error to="kill"/>
123+
</action>
124+
<kill name="kill">
125+
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
126+
</kill>
127+
<end name="end"/>
128+
</workflow-app>
129+
```
130+
131+
### 四. coordinator语法:
132+
#### 4.1 coordinator.xml
133+
```xml
134+
<coordinator-app name="clear-stat-coordinator" frequency="*/10 0-17,20-23 * * *" start="${start}" end="${end}" timezone="Asia/Shanghai"
135+
xmlns="uri:oozie:coordinator:0.2">
136+
<action>
137+
<workflow>
138+
<app-path>${workflowAppUri}</app-path>
139+
<configuration>
140+
<property>
141+
<name>jobTracker</name>
142+
<value>${jobTracker}</value>
143+
</property>
144+
<property>
145+
<name>nameNode</name>
146+
<value>${nameNode}</value>
147+
</property>
148+
<property>
149+
<name>queueName</name>
150+
<value>${queueName}</value>
151+
</property>
152+
</configuration>
153+
</workflow>
154+
</action>
155+
</coordinator-app>
156+
157+
```
158+
#### 4.2 job.properties
159+
```typescript
160+
nameNode=hdfs://cluster
161+
jobTracker=master
162+
examplesRoot=oozie-apps
163+
queueName=task
164+
165+
# oozie.wf.application.path 标识这是一个workflow任务。
166+
# oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/clear-stat-coordinator/workflow.xml
167+
oozie.coord.application.path=${nameNode}/user/${user.name}/${examplesRoot}/clear-stat-coordinator/coordinator.xml
168+
sparkopts=--executor-cores 1 --executor-memory 1g --num-executors 8 --queue ${queueName} --conf spark.yarn.maxAppAttempts=1
169+
workflowAppUri=${nameNode}/user/${user.name}/${examplesRoot}/clear-stat-coordinator
170+
jarPath=lib/SparkTasks.jar
171+
statClass=com.wangdian.spark.tasks.main.stat.ExecuteSparkSqlTask
172+
clearClass=com.wangdian.spark.tasks.main.clear.StatDateClearApiTrade
173+
distinctClass=com.wangdian.spark.tasks.main.clear.HiveGoodsDistinctAndCategoryStatistics
174+
start=2020-01-09T15:00+0800
175+
end=2020-01-11T17:45+0800
176+
177+
```
178+
179+
### 五. 使用脚本来节省时间:
180+
##### 由于每次提交任务都要上传到集群上,所以将这些命令自动化
181+
任务提交:
182+
`./start.sh 文件包名`
183+
184+
```bash
185+
jarNumStr=`ls -ll /data/bin/oozie-apps/spark-jar-warehouse | grep SparkTasks.jar* | wc -l`
186+
jarNum=${#jarNumStr}
187+
min=1
188+
if [ $jarNum -gt $min ]; then
189+
echo "SparkTasks.jar类似文件存在多个,请保证一个最新版本"
190+
exit 1
191+
fi
192+
hadoop fs -rm -r /user/hdfs/oozie-apps/$1
193+
hadoop fs -put $1 /user/hdfs/oozie-apps/
194+
oozie job -oozie http://hadoop03:11000/oozie -config $1/job.properties -run
195+
```
196+
197+
### 六. 常见实例图解:
198+
#### 6.1 执行开始:
199+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578829307117-869414b3-ca89-4acf-9fb0-da713a6a4b04.png#align=left&display=inline&height=4685&name=image.png&originHeight=4685&originWidth=3205&size=1010853&status=done&style=none&width=3205)
200+
#### 6.2 执行完毕:
201+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578829331612-9adb0d24-879b-4e2c-a496-e3c564f78c9b.png#align=left&display=inline&height=4175&name=image.png&originHeight=4175&originWidth=2345&size=654169&status=done&style=none&width=2345)
202+
### 七.ooize执行,长时间处于prep的一次优化
203+
#### 7.1 ooize prep状态
204+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578829431409-2bdb3c36-300a-4b89-be3b-c0c0f65cfd57.png#align=left&display=inline&height=723&name=image.png&originHeight=723&originWidth=1046&size=88102&status=done&style=none&width=1046)
205+
#### 7.2发现原因是Yarn 中application太多了,导致两个问题:1.页面访问变慢2.ooize提交任务变慢
206+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578829730063-871a2132-68b6-436f-b81f-85f1497566ca.png#align=left&display=inline&height=654&name=image.png&originHeight=654&originWidth=639&size=69720&status=done&style=none&width=639)
207+
#### 7.3 解决办法:
208+
209+
1. 删除log日志10000多个appl,省出大概800G空间,  (自己集群设置的hdfs的位置)
210+
1. 删除zk上applacation任务,  (默认位置:  `zookeeper中:  rmr /rmstore/ZKRMStateRoot/RMAppRoot` )
211+
1. 重启ooize
212+
213+
214+
215+
216+
- 删除前
217+
218+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578829568732-7c377e3f-4a5b-4f49-a2c9-8400601b6460.png#align=left&display=inline&height=142&name=image.png&originHeight=142&originWidth=1373&size=78397&status=done&style=none&width=1373)
219+
220+
- 删除后:
221+
222+
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578829607117-a2e78395-df1a-4f08-8097-40a8476b6e7e.png#align=left&display=inline&height=152&name=image.png&originHeight=152&originWidth=1001&size=15448&status=done&style=none&width=1001)
223+
**最后问题解决!**
224+
225+
### Reference
226+
227+
* [ooize官网](http://oozie.apache.org/)
228+
* [什么是Oozie——大数据任务调度框架](https://blog.csdn.net/TNTZS666/article/details/81915820)
229+
* [ooize学习](https://www.cnblogs.com/cac2020/p/10509950.html)

_posts/2019/2019-09-30-scheduling-framework.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ tags:
6464
![image.png](https://cdn.nlark.com/yuque/0/2020/png/152121/1578464849952-627880c5-780f-4e87-83e7-d6071fd5c77e.png)
6565
<center>图1:Linux/ooize 舍弃了秒的存在</center>
6666

67-
6867
#### 1.5 Cron eg:
6968

7069
- 0 0 12 ? * WED(每星期三下午12:00 执行)
@@ -334,7 +333,7 @@ public static void main(String[] args) throws SchedulerException, InterruptedExc
334333

335334
## 3. 集群调度任务ooize
336335

337-
详情见我的: [**ooize使用到精通**](https://githubdingyun.github.io/2019/10/24/how-to-use-ooize/)
336+
详情见我的: [**ooize使用到精通**](https://githubdingyun.github.io/2019/08/25/how-to-use-ooize/)
338337

339338
## Refrence
340339

img/ooize.png

809 KB
Loading

0 commit comments

Comments
 (0)