sqoop导出数据到关系数据库export_fact_bi_browser_t_job.sh
#!/bin/bash
###################################
# code review heguoxiu@berchina.com 20170504
# System Name : 大数据智慧分析平台
# Author : heguoxiu
# Description : sqoop导出数据到oracle
##################################
#引用公共变量配置文件
source /parse/opt/shell/public/public_time.cfg
#####oracle配置文件######
source /parse/opt/shell/public/public_db.cfg
#导出到oracle关系数据库对应表及字段
v_name="BI_BROWSER"
v_columns="ID,BI_TYPE,BR_NAME,BI_VALUE,BI_DATETIME,BI_CHANNEL"
#把hive目标表对应的表目录赋值变量
hdfs_dir="/RESULT/PARSEDB/FACT_${v_name}_T/year=${year}/month=${month}/day=${day}"
echo "###开始导出${v_name}: `date +"%Y-%m-%d %H:%M:%S"`"
sudo -u hdfs sqoop eval --connect ${v_host}:${v_port}:${v_database} --username ${v_username} --password ${v_password} --query "truncate table ${v_name}" &&
sudo -u hdfs sqoop export --connect ${v_host}:${v_port}:${v_database} --username ${v_username} --password ${v_password} --table ${v_name} \
--export-dir ${hdfs_dir} --fields-terminated-by '\001' --input-null-string '\\N' \
--input-null-non-string '\\N' --columns ${v_columns} -m 3
echo "###导出结束${v_name}: `date +"%Y-%m-%d %H:%M:%S"`"