hive表增量抽取到oracle数据库的通用程序(二)
前一篇介绍了java程序的如何编写、使用以及引用到的依赖包。这篇接着上一篇来介绍如何在oozie中使用该java程序。
在我的业务中,分为两段:
1. 查询hive表中的信息,通过oozie可以设置不同的变量作为增量查询的条件。
2. 将hive查询到的信息写入到oracle中。
对应oozie中的workflow文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<workflow-app xmlns="uri:oozie:workflow:0.4" name="wf_${job_name}_day">
<start to="hive-node"/> <!-- 统计day: dm_guba_loginlog -->
<action name="hive-node" retry-max="10" retry-interval="3">
<hive xmlns="uri:oozie:hive-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<job-xml>${hive_site_path}</job-xml>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<script>script.q</script>
<param>tmp_table=tmp_dm_xxx_day</param>
<param>params_dt=${params_dt}</param>
</hive>
<ok to="java-node"/>
<error to="senderror"/>
</action> <!-- 注意:hive_hql,rdms_presql语句结尾不能使用分号 -->
<action name="java-node">
<java>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<main-class>com.exe.Hive2RMDS</main-class>
<arg>--hive_url</arg>
<arg>jdbc:hive2://xx.xx.xx.xx:10000/default</arg>
<arg>--hive_hql</arg>
<arg>select field1,field2,field3,dim,period,period_value from dw_dm.dm_xxx where period = 'day' and period_value = ${params_dt}</arg>
<arg>--rdms_driver</arg>
<arg>oracle.jdbc.driver.OracleDriver</arg>
<arg>--rdms_url</arg>
<arg>jdbc:oracle:thin:@xx.xx.xx.xx:1521:test001</arg>
<arg>--rdms_username</arg>
<arg>DW_test</arg>
<arg>--rdms_password</arg>
<arg>DW_test</arg>
<arg>--rdms_tableName</arg>
<arg>DW_DM.DM_xxx_TEST</arg>
<arg>--rdms_columnNames</arg>
<arg>field1,field2,field3,dim,period,period_value</arg>
<arg>--rdms_presql</arg>
<arg>delete from DW_DM.DM_xxx_TEST where period = 'day' and period_value = '${params_dt}'</arg> </java>
<ok to="end"/>
<error to="senderror"/>
</action>
<!--出错发送邮件 -->
<action name="senderror">
<email xmlns="uri:oozie:email-action:0.1">
<to>xxx@qq.com</to>
<subject>${job_name} log error in ${params_dt}</subject>
<body>Error: ${params_dt} ,error message[${wf:errorMessage(wf:lastErrorNode())}]</body>
</email>
<ok to="fail"/>
<error to="fail"/>
</action> <kill name="fail">
<message>workflow: ${wf:id()}, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/> </workflow-app>
以下为在oozie中的执行过程提示信息:

总结:
该程序相对来说比较通用,可以在导入oracle前,预先执行一段sql语句用于清除oracle中已有的记录。
通过批处理导入,执行效率比较高。
通常用于将汇总的结果导出到关系型数据库中,然后通过关系型数据库直接展示到BI报表系统中。
hive表增量抽取到oracle数据库的通用程序(二)的更多相关文章
- hive表增量抽取到oracle数据库的通用程序(一)
hive表增量抽取到oracle数据库的通用程序(二) sqoop在export的时候 只能通过--export-dir参数来指定hdfs的路径.而目前的需求是需要将hive中某个表中的多个分区记录一 ...
- hive表增量抽取到mysql(关系数据库)的通用程序(三)
hive表增量抽取到oracle数据库的通用程序(一) hive表增量抽取到oracle数据库的通用程序(二) 这几天又用到了该功能了,所以又改进了一版,增加了全量抽取和批量抽取两个参数.并且可以设置 ...
- Oracle数据库基础入门《二》Oracle内存结构
Oracle数据库基础入门<二>Oracle内存结构 Oracle 的内存由系统全局区(System Global Area,简称 SGA)和程序全局区(Program Global Ar ...
- 细说Oracle数据库与操作系统存储管理二三事
在上大学的时候,学习操作系统感觉特别枯燥,都是些条条框框的知识点,感觉和实际应用的关联不大.发现越是工作以后,在工作中越想深入了解,发现操作系统知识越发重要.在实践中结合理论还是不错的一种学习方法.自 ...
- 在.NET开发面向Oracle数据库的应用程序
其实这个不是一个什么新的话题.但是之前在多次项目中,总是遇到大家针对Oracle数据库的访问时,会有各种各样的问题,最基本的就是要在客户端安装各种client,版本不一样的话还有各种问题. 静下心来看 ...
- oozie4.3.0+sqoop1.4.6实现mysql到hive的增量抽取
1.准备数据源 mysql中表bigdata,数据如下: 2. 准备目标表 目标表存放hive中数据库dw_stg表bigdata 保存路径为 hdfs://localhost:9000/user/h ...
- 一条sql,有分页,表合并查询,多表连接,用于oracle数据库
SELECT * FROM ( SELECT TT.*,ROWNUM RN FROM ( SELECT A.CASE_ID AS TREATID, A.TYPE AS TYPE, B.CONTENT ...
- Java连接Oracle数据库开发银行管理系统【二、设计篇】
一.总体分析 此系统的实现并不难,但是如何更好的设计出实现方式还是需要更深入的分析,例如:如果再增加其他功能,是不是需要变动的 代码很少,只是直接再增加一点功能就可以了呢?如果使用的不是Ora ...
- Oracle数据库操作---基础使用(二)
此篇承接上一篇的基本原理,继续展开学习,本篇主要面向数据的使用和管理,也就是开发者常用的基础语句,开始喽…… >>>对整表的操作 >创建表 关键字 Create creat ...
随机推荐
- proguard的简单配置说明
#需要转换的jar文件路径-injars 'D:\fs-np.jar'#转换后的jar文件名称-outjars 'D:\fs-np-sec.jar' #关联的第三方jar-libraryjars 'C ...
- Android ListView and Tips.
Tips: ListView嵌套ListView,有footerView时.须要又一次measure高度时,footerview最顶层的view不能是RelativeLayout,最好用LinearL ...
- pyspark dataframe 常用操作
spark dataframe派生于RDD类,但是提供了非常强大的数据操作功能.当然主要对类SQL的支持. 在实际工作中会遇到这样的情况,主要是会进行两个数据集的筛选.合并,重新入库. 首先加 ...
- 基于PHPExcel常用方法总结(phpexcel类库实例)
分享下对PHPExcel的常用方法进行详细的总结与分析. 对phpexcel类库不熟悉的朋友,可以阅读下<phpexcel中文帮助手册>中的内容,具体实例大家可以phpexcel快速开发指 ...
- 关于ios7的适配问题
过年回来一直搞ios7的项目适配,也算是有些眉目. 方法一:直接动用Window #if __IPHONE_OS_VERSION_MAX_ALLOWED>=__IPHONE_7_0 [appli ...
- 【Unity】5.2 天空盒
分类:Unity.C#.VS2015 创建日期:2016-04-20 一.简介 Unity中的天空盒实际上是一种使用了特殊类型Shader的材质,这种类型的材质可以笼罩在整个游戏场景之外,并根据材质中 ...
- Debugging the Java HotSpot VM
Open Heart Surgery: Analyzing and Debugging the Java HotSpot VM at the OS Level https://www.youtube. ...
- Linux系统Apache服务 - 配置 HTTP 的虚拟机主机
接Linux系统Apache服务 - 配置HTTP的默认主页 1.创建/srv目录,作为httpd的文件目录,并创建/srv/default/www和/srv/www1.example.com/www ...
- centos 7 min 编译安装php5.6+nginx1.7.5 笔记
1.安装mysql请参照 centos 7 min 编译安装mysql5.6.20 笔记 2.编译安装php5.6+nginx1.7.5 2.1.安装php5.6.0 首先添加依赖应用yum inst ...
- Android 开发添加控件事件的三种方式
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view ...