[Ganzhou] shell script for synchronous update of hive data

Source: Internet
Author: User
Tags cron script sqoop
Introduction:In the previous article, the incremental data in Oracle10g is imported into hive0.13.1, and the master table in hive is updated. http://blog.csdn.net/u010967382/article/details/38735381 describes the principle of incremental update hive table and sqoop, hive command, based on the content of the previous article, this article implements shell script writing, which can be used for actual projects with slight modifications. * ** You are welcome to reprint it. Please specify the source ***
Http://blog.csdn.net/u010967382/article/details/38824327 Shell script
#! /Bin/bash
# Please set the synchronize interval, unit is hour. update_interval = 24
# Please set the RDBMS connection paramsrdbms_connstr = "JDBC: oracle: thin :@192.168.0.147: 1521: orclgbk "rdbms_username =" SP "partition =" Fulong "rdbms_table =" omp_service "rdbms_columns =" ID, SERVICE_NAME, service_process, create_time, enable_org, enable_platform, if_del"
# Please set the hive paramshive_increment_table = "service_tmp" hive_full_table = "service_all"
#---------------------------------------------------------
# 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 $ {region} -- 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. * From $ {hive_full_table} A left Outer Join $ {hive_increment_table} B on. service_code = B. service_code where B. service_code is null ;" Note:The command format for executing hive hql in shell scripts is hive-e "Select ..." Cron scriptAdd a scheduled task to execute the script 0 2 ***/home/Fulong/Shell/datasync. Sh at every day.

[Ganzhou] shell script for synchronous update of hive data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.