sqoop导入数据配置
从mysql导入到hdfs
全量导入:
$ bin/sqoop import \
--connect jdbc:mysql://10.190.xx.xx:3306/${db_name} \
--username ${username} \
--password ${password} \
--table ${table_name} \
--target-dir /${target_file_path} \
--delete-target-dir \
--num-mappers ${int_num} \
--fields-terminated-by "\t"
查询导入:
$ bin/sqoop import \
--connect jdbc:mysql://10.190.xx.xx:3306/${db_name} \
--username ${username} \
--password ${password} \
--target-dir /${target_file_path} \
--delete-target-dir \
--num-mappers ${int_num} \
--fields-terminated-by "\t" \
--query 'select name,sex from persion where id <=1 and $CONDITIONS;'
从hdfs导出到mysql
$ bin/sqoop export \
--connect "jdbc:mysql://10.190.xx.xx:3306/${db_name}?useUnicode=true&characterEncoding=utf-8" \
--username ${username} \
--password ${password} \
--table ${table_name} \
--num-mappers ${int_num} \
--export-dir /warehouse/$db_name/ads/$1 \
--input-fields-terminated-by "\t" \
--update-mode allowinsert \
--update-key "tm_id,category1_id,stat_mn,stat_date" \
--input-null-string '\\N' \
--input-null-non-string '\\N'