oozie與hive的簡單案例


1.把oozie中自帶的hive案例拷貝到 測試目錄 /opt/cdh-5.3.6/oozie-4.0.0-cdh5.3.6/oozie-apps下

2. 編輯 job.properties

 1 #
 2 # Licensed to the Apache Software Foundation (ASF) under one
 3 # or more contributor license agreements.  See the NOTICE file
 4 # distributed with this work for additional information
 5 # regarding copyright ownership.  The ASF licenses this file
 6 # to you under the Apache License, Version 2.0 (the
 7 # "License"); you may not use this file except in compliance
 8 # with the License.  You may obtain a copy of the License at
 9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 nameNode=hdfs://hadoop:8020
19 jobTracker=hadoop:8032
20 queueName=default
21 oozieAppsRoot=user/root/oozie-apps
22 oozieDataRoot=user/root/oozie/datas
23 
24 oozie.use.system.libpath=true
25 
26 oozie.wf.application.path=${nameNode}/${oozieAppsRoot}/hive-select/
27 
28 outputDir=hive-select/output

3.拷貝hive的配置文件hive-site.xm

4.拷貝mysql的jar包

 

5.編輯workflow.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!--
 3   Licensed to the Apache Software Foundation (ASF) under one
 4   or more contributor license agreements.  See the NOTICE file
 5   distributed with this work for additional information
 6   regarding copyright ownership.  The ASF licenses this file
 7   to you under the Apache License, Version 2.0 (the
 8   "License"); you may not use this file except in compliance
 9   with the License.  You may obtain a copy of the License at
10 
11        http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 -->
19 <workflow-app xmlns="uri:oozie:workflow:0.5" name="wf-hive-select">
20     <start to="hive-node"/>
21 
22     <action name="hive-node">
23         <hive xmlns="uri:oozie:hive-action:0.5">
24             <job-tracker>${jobTracker}</job-tracker>
25             <name-node>${nameNode}</name-node>
26             <prepare>
27                 <delete path="${nameNode}/${oozieDataRoot}/${outputDir}"/>
28             </prepare>
29             <job-xml>${nameNode}/${oozieAppsRoot}/hive-select/hive-site.xml</job-xml>
30             <configuration>
31                 <property>
32                     <name>mapred.job.queue.name</name>
33                     <value>${queueName}</value>
34                 </property>
35             </configuration>
36             <script>select-student.sql</script>
37             <param>OUTPUT=${nameNode}/${oozieDataRoot}/${outputDir}</param>
38         </hive>
39         <ok to="end"/>
40         <error to="fail"/>
41     </action>
42 
43     <kill name="fail">
44         <message>Hive failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
45     </kill>
46     <end name="end"/>
47 </workflow-app>

6.編輯sql腳本 select-student.sql

--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements.  See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership.  The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License.  You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
insert overwrite directory '${OUTPUT}' select count(1) from hive_bbs_product_snappy;

 

7.把配置文件上傳至hdfs

1 bin/hdfs dfs -put /opt/cdh-5.3.6/oozie-4.0.0-cdh5.3.6/oozie-apps/hive-select/ /user/root/oozie-apps

 

8.提交任務 

    1) 啟動oozie

1 bin/oozied.sh start

   2)提交

1 export OOZIE_URL=http://localhost:11000/oozie
  bin/oozie job -config oozie-apps/hive-select/job.properties -run

 

測試成功!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM