shell操作sqoop从hive导出到mysql(使用hive数据文件导入)

#!/bin/bash
export_method(){
V_DATE=`date --date="-1 day" +%Y%m%d`
V_TABLE=app_member_sales_order_di
D_BASE=data_center_ods
user=root
D_PASSWORD=Trtjk1234@
D_schema=shop_one
#mysql的表
T_TABLE=app_member_sales_order_di
CONNECT=jdbc:mysql://10.8.154.235:3306/shop_one?characterEncoding=utf-8
#hive表数据存放路径(hive建表时数据存放路径)
T_DIR=/onebase/app/${V_TABLE}/pt=${V_DATE}
#mysql对应字段
T_column=id,member_phone,create_time,order_no,amount,account_period

sqoop export \
--connect $CONNECT \
--username $user \
--driver org.postgresql.Driver \
--password $D_PASSWORD \
--table $T_TABLE \
--export-dir $T_DIR \
--columns $T_column \
--input-fields-terminated-by '\001' \
--input-lines-terminated-by '\n' \
--input-null-string "\\\\N" \
--input-null-non-string "\\\\N"
}
export_method

你可能感兴趣的:(sqoop,mysql,hive)