修炼离线:(七)sqoop同步MySQL数据到hive

一:同步脚本。

#!/bin/sh

mysqlHost=$1
mysqlUserName=$2
mysqlUserPass=$3
mysqlDbName=$4
myqlTbName=$5
hiveDbName=$6
hiveTbName=$7
partFieldName=$8
inputDate=$9

echo ${mysqlHost}
echo ${mysqlUserName}
echo ${mysqlUserPass}
echo ${mysqlDbName}
echo ${myqlTbName}
echo ${hiveDbName}
echo ${hiveTbName}
echo ${partFieldName}
echo ${inputDate}


sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect jdbc:mysql://${mysqlHost}/${mysqlDbName}?tinyInt1isBit=false \
--username ${mysqlUserName} \
--password ${mysqlUserPass} \
--table ${myqlTbName} \
--hive-overwrite \
--delete-target-dir \
--fields-terminated-by '\t' \
--null-string "" \
--hive-import \
--null-non-string "false" \
--hive-database ${hiveDbName} \
--hive-table ${hiveTbName} \
--hive-drop-import-delims \
--hive-partition-key ${partFieldName} \
--hive-partition-value ${inputDate}

二:同步命令。

sh mysql_hive.sh xx.xx.xx.xx:3306 \
 root 123456 dongfeng bluetooth_device ods ods_dk_bluetooth_idk_bluetooth_device_test p_dt 2023-09-19

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