通过sqoop增量传送oracle数据到hive
来源:互联网 发布:广州中名软件 编辑:程序博客网 时间:2024/06/05 02:15
从网上看到的一个oracle数据通过sqoop每日增量同步到hive的shell脚本,感觉以后会有用,作为参考,备查。
[spark@store ~]$ cat oracle2hive_imcrement.sh
#!/bin/bash#Please set the synchronize interval,unit is hour.update_interval=24#Please set the RDBMS connection paramsrdbms_connstr="jdbc:oracle:thin:@WIN-A1UAC36B1UC:1521:orcl"rdbms_username="cfa"rdbms_pwd="cfa"rdbms_table="AIX_REPORT_DATA"rdbms_columns="reportno,rowno,rowname,col2value,create_time"#Please set the hive paramshive_increment_table="aix_report_data_increment"hive_full_table="aix_report_data"#---------------------------------------------------------#Import icrement data in RDBMS into Hiveenddate=$(date '+%Y/%m/%d %H:%M:%S')startdate=$(date '+%Y/%m/%d %H:%M:%S' -d '-'+${update_interval}+' hours')$SQOOP_HOME/bin/sqoop import --connect ${rdbms_connstr} --username ${rdbms_username} --password ${rdbms_pwd} --table ${rdbms_table} --columns "${rdbms_columns}" --where "CREATE_TIME > to_date('${startdate}','yyyy-mm-dd hh24:mi:ss') and CREATE_TIME < to_date('${enddate}','yyyy-mm-dd hh24:mi:ss')" --hive-import --hive-overwrite --hive-table ${hive_increment_table}#---------------------------------------------------------#Update the old full data table to latest status$HIVE_HOME/bin/hive -e "insert overwrite table ${hive_full_table} select * from ${hive_increment_table} union all select a.* from ${hive_full_table} a left outer join ${hive_increment_table} b on a.reportno = b.reportno and a.rowno = b.rowno where b.reportno is null;"
从脚本中主要学习了,变量参数的使用、hive下增量数据的又一算法、sqoop中where过滤的使用等。
另:通过spark-shell执行sql的样例:
sqlContext.sql("select * from 99_dorm limit 100").show
0 0
- 通过sqoop增量传送oracle数据到hive
- 使用 sqoop从MySQL增量导出数据到hive
- sqoop 导oracle数据到hive
- 利用sqoop导出hive数据到 oracle
- Sqoop 连接Oracle导入数据到hive
- Sqoop全量和增量导入数据到Oracle数据库
- 通过Sqoop工具将Oracle数据库中的表数据导入到Hive的过程
- sqoop导oracle.mysql数据到hdfs hive
- Sqoop工具使用(一)--从oracle导入数据到hive
- 使用sqoop将oracle数据迁移到hive中
- 从Hive导出数据到Oracle数据库--Sqoop
- oozie定时调用sqoop从oracle中增量导入数据至hive表
- sqoop导入数据到hive
- sqoop导入数据到hive
- Sqoop导入数据到Hive
- Sqoop增量导入Hive
- Sqoop数据迁移,工作机制,sqoop安装(配置),Sqoop的数据导入,导入表数据到HDFS,导入关系表到HIVE,导入到HDFS指定目录,导入表数据子集,按需导入,增量导入,sqoop数据导出
- 通过Sqoop工具将Oracle数据导入到HBase
- 【杭电-oj】-1509-Windows Message Queue(优先队列)
- 判断苹果各种智能手机设备型号
- android namevaluepair 过时
- android中子线程更新UI的几种方法
- 【那些年遇到过的面试题】netstat/tcpdump/traceroute/ss/probe
- 通过sqoop增量传送oracle数据到hive
- php openssl rsa 加密解密应用
- java三大特性之————封装
- 20160630整理到cloudeye攻击的一些姿势
- Android中ListView分页加载数据
- idea常用配置
- RecyclerView--监测View是否可以沿着指定方向滑动
- STC双串口单片机无法烧写下载程序原因,普中开发箱,STC12C5A60S2
- Timus 1892 Morning in Koltsovo