第一步: 将shell拷贝到/opt/modules/oozie/oozie-apps/下
cp -r shell/ ../../oozie-apps/
这里用来测试shell脚本,内容是测试hive命令
第二步: 编写脚本文件,文件名为script.sh文件,内容如下:
#!/bin/bash
/opt/modules/hive/bin/hive -f $1
第三步: 对script.sh文件赋予权限
chmod 777 script.sh
第四步: 编写hive sql文件,文件名为hive.sql,内容如下:
select * from db_hive.order
第五步: 依据官方example,编写job.properties文件,内容如下:
nameNode=hdfs://bigdata-pro-m01:9000
jobTracker=bigdata-pro-m01:8032
queueName=default
oozieAppRoot=user/caizhengjie/oozie-apps
oozieDataRoot=user/caizhengjie/oozie-datas
oozie.wf.application.path=${nameNode}/${oozieAppRoot}/shell
EXEC=script.sh
SQL=hive.sql
第六步: 编写workflow文件,内容如下:
<workflow-app xmlns="uri:oozie:workflow:0.5" name="shell-wf">
<start to="shell-node"/>
<action name="shell-node">
<shell xmlns="uri:oozie:shell-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>${EXEC}</exec>
<argument>${SQL}</argument>
<file>${nameNode}/${oozieAppRoot}/shell/${EXEC}#${EXEC}</file>
<file>${nameNode}/${oozieAppRoot}/shell/${SQL}#${SQL}</file>
</shell>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Incorrect output, expected [Hello Oozie] but was [${wf:actionData('shell-node')['my_output']}]</message>
</kill>
<end name="end"/>
</workflow-app>
第七步: 如果hive和Hadoop不在同一节点上,需要拷贝hive的安装目录到hadoop服务的节点上,保证shell脚本中的/opt/modules/hive/bin/hive命令能找到对应的安装目录
第八步: 上传shell整个目录到HDFS上
bin/hdfs dfs -put /opt/modules/oozie/oozie-apps/shell /user/caizhengjie/oozie-apps
第九步: 运行测试
bin/oozie job -oozie http://bigdata-pro-m01:11000/oozie -config oozie-apps/shell/job.properties -run
以上内容仅供参考学习,如有侵权请联系我删除!
如果这篇文章对您有帮助,左下角的大拇指就是对博主最大的鼓励。
您的鼓励就是博主最大的动力!