123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/bash
- . /opt/app/bi-app/energy/dayTask/config.sh
- if [ -n "$2" ] ;then
- echo "如果是输入的日期按照取输入日期"
- do_date=$2
- else
- echo "====没有输入数据的日期,取当前时间的前一天===="
- do_date=`date -d yesterday +"%Y-%m-%d"`
- fi
- url=$MYSQL_URL
- username=$MYSQL_USER
- password=$MYSQL_PASSWORD
- hdfs_to_mysql() {
- sqoop export -D mapred.job.queue.name=hive \
- --connect $1 \
- --username $2 \
- --password $3 \
- --table $4 \
- -m 1 \
- --hcatalog-database saga_dw \
- --hcatalog-table $5 \
- --fields-terminated-by '\001' \
- --input-null-string '\\N' \
- --input-null-non-string '\\N'
- }
- hdfs_to_mysql_by_day() {
- sqoop export -D mapred.job.queue.name=hive \
- --connect $1 \
- --username $2 \
- --password $3 \
- --table $4 \
- -m 1 \
- --hcatalog-database saga_dw \
- --hcatalog-table $5 \
- --hcatalog-partition-keys dt \
- --hcatalog-partition-values $do_date \
- --fields-terminated-by '\001' \
- --input-null-string '\\N' \
- --input-null-non-string '\\N'
- }
- app_energy(){
- hdfs_to_mysql $url $username $password "app_energy_15_min" "dwd_energy_15_min_hour"
- }
- app_energy_day(){
- hdfs_to_mysql_by_day $url $username $password "app_energy_15_min" "dwd_energy_15_min_hour"
- }
- case $1 in
- "app_energy")
- app_energy
- ;;
- "app_energy_day")
- app_energy_day
- ;;
- esac
|