zoukankan      html  css  js  c++  java
  • 定时每天执行前一天的数据导入oracle

    #!/bin/bash
    export LANG="en_US.UTF-8"

    #设定时间变量,为前一天时间
    log_date=`date +%Y-%m-%d -d "-1 days"`
    #清空hive上的数据,再重建一个文件夹 hadoop dfs
    -rm -r /hjh/channels hadoop dfs -mkdir /hjh/channels
    #设置文件路径 curr_dir
    ="/home/hadoop/hjh/sh/channels/runlastdaychannels/" temdir="${curr_dir}template/" hqlfiledir="${curr_dir}hqlfile/"
    #设置hql的文件路径 importTemFile
    ="${temdir}channels.hql" importHqlFile="${hqlfiledir}channels_${log_date}.hql" rm -f ${importHqlFile} cp ${importTemFile} ${importHqlFile}
    #发送hql文件到另一个文件夹 sed
    -i "s/__DATE_STR__/${log_date}/g" ${importHqlFile} /opt/hive-0.13.0/bin/hive -f ${importHqlFile}
    #把执行之后hdfs上的数据导入到oracle
    /opt/sqoop-1.4.4/bin/sqoop export --table mytablename --connect jdbc:oracle:thin:@**.**.**.**:***:dbasename --username myusername--password mypassword
    --export-dir /result/hive/***/000000_0 --columns column1,column2,column3
    --input-fields-terminated-by '01' --input-lines-terminated-by ' '
  • 相关阅读:
    141. Linked List Cycle
    140. Word Break II
    139. Word Break
    138. Copy List with Random Pointer
    137. Single Number II
    136. Single Number
    135. Candy
    134.Gas Station
    linux/ubuntu 设置代理服务器
    sqlserver/mssql 查看版本信息
  • 原文地址:https://www.cnblogs.com/aijianiula/p/4895554.html
Copyright © 2011-2022 走看看