說明:使用 shell action 執行 shell 腳本 hive-select-test.sh 來經過已經配置好的 Hive -f 來執行 HQL 查詢腳本文件 select.sqlnode
#!/bin/sh /opt/cdh5.3.6/hive-1.1.0-cdh5.12.0/bin/hive -f select.sql
insert overwrite directory '/user/cen/oozie-apps/shell-hive-select/output/' select count(1) cnt from default.test;
nameNode=hdfs://cen-ubuntu.cenzhongman.com:8020 jobTracker=localhost:8032 queueName=default oozieAppsRoot=oozie-apps oozie.wf.application.path=${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/ EXEC=hive-select-test.sh script=select.sql
<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> <file>${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/${EXEC}#${EXEC}</file> <file>${nameNode}/user/cen/${oozieAppsRoot}/shell-hive-select/${script}#${script}</file> </shell> <ok to="end"/> <error to="fail"/> </action> <kill name="fail"> <message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> </kill> <end name="end"/> </workflow-app>
export OOZIE_URL=http://cen-ubuntu:11000/oozie/ bin/oozie job --config oozie-apps/shell-hive-select/job.properties -run