Shell script for synchronous update of Hive data

Source: Internet
Author: User
Tags cron script sqoop

Shell script for synchronous update of Hive data
Introduction: in the previous article Sqoop1.4.4, import incremental data from Oracle10g to Hive0.13.1 and update the master table in Hive describes the principle of incremental update of Hive tables and Sqoop and Hive commands, based on the content of the previous article, this article implements shell script writing, which can be used for actual projects with slight modifications. 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 "# partition # 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} # metadata # 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 ..." The Cron script adds a scheduled task to execute this script at every day 0 2 ***/home/fulong/shell/dataSync. sh

Hadoop cluster-based Hive Installation

Differences between Hive internal tables and external tables

Hadoop + Hive + Map + reduce cluster installation and deployment

Install in Hive local standalone Mode

WordCount word statistics for Hive Learning

Hive operating architecture and configuration and deployment

Hive details: click here
Hive: click here

This article permanently updates the link address:

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.