zoukankan      html  css  js  c++  java
  • 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

     

    测试成功!

  • 相关阅读:
    webpack.DefinePlugin
    webpack-dev-server配置指南(使用webpack3.0)
    Eclipse配色方案插件
    解决Sublime Text 3中文显示乱码问题(转)
    Java连接SqlServer2008数据库
    [转]java中判断字符串是否为数字的三种方法
    VS2008 SP1 安装卡在 VS90sp1-KB945140-X86-CHS的解决方法
    Python获取桌面路径
    关于fdisk命令
    socket 错误之:OSError: [WinError 10057] 由于套接字没有连接并且(当使用一个 sendto 调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。
  • 原文地址:https://www.cnblogs.com/xuyou551/p/8059472.html
Copyright © 2011-2022 走看看