Sqoop:
查询导入
bin/sqoop import
--connect jdbc:mysql://hadoop102:3306/company
--username root
--password 123456
--target-dir /user/company
--delete-target-dir
--num-mappers 1
--fields-terminated-by " "
--query 'select name,sex from staff where id<=1 and $CONDITIONS;'
全部导入
bin/sqoop import
--connect jdbc:mysql://hadoop102:3306/company
--username root
--password 123456
--table staff
--target-dir /user/company
--delete-target-dir
--num-mappers 1
--fields-terminated-by " "
指定列:--columns id,sex
条件:where ""
导入到HIVE:
bin/sqoop import
> --connect jdbc:mysql://hadoop102:3306/company
> --username root
> --password 123456
> --table staff
> --num-mappers 1
> --hive-impo
> --fields-terminated-by " "
> --hive-overwrite
> --hive-table 数据库名.staff_hive
导出:
bin/sqoop export
--connect jdbc:mysql://hadoop102:3306/hivetest
--username root
--password 123456
--table bigtest
--num-mappers 1
--export-dir /user/hive/warehouse/bigtest
--input-fields-terminated-by ","
脚本:
bin/sqoop --options-file job/sqp.opt