0 如下所有命令 在命令行应该写成一行 这里是为了读取方便而故意折行写出来
1 sqoop mysql
mysql ---> hdfs
sqoop import --connect jdbc:mysql://172.16.252.227:3306/test --username root --password root --table testzm --columns 'id,name'
--target-dir /user/root/example/output-dir/testmysql -m 1
--fields-terminated-by "\t" --null-string "**" --null-non-string "##";
hdfs ---> mysql
sqoop export --connect jdbc:mysql://172.16.252.227:3306/test --username root --password root --table testzmexport
--export-dir /user/root/example/output-dir/testmysql/part-m-00000 -m 1
--fields-terminated-by "\t" ;
2 sqoop oracle
oracle库为ORCL 表为 USERINFO
oracle ---> hdfs
sqoop import --connect jdbc:oracle:thin:@172.16.252.227:1521:orcl --username test_user --password oracle --table USERINFO
--target-dir /user/root/example/output-dir/sqoop-from-oracl -m 1
--fields-terminated-by "\t" --null-string "**" --null-non-string "##";
oracle ---> hive
sqoop import --connect jdbc:oracle:thin:@172.16.252.227:1521:orcl --username test_user --password oracle --table USERINFO
--hive-import -m 1; 此时hive不需要创建表名和字段,会默认使用关系型数据库表名,和关系型数据库的字段。
hdfs ---> oracl
sqoop export --connect jdbc:oracle:thin:@172.16.252.227:1521:orcl --username test_user --password oracle --table test_user_export
--export-dir /user/root/example/output-dir/testmysql/part-m-00000 -m 1
--fields-terminated-by "\t" ;
3 sqoop sqlserver
1 sqlserver
sqlserver ---> hdfs
sqoop import --connect 'jdbc:sqlserver://172.16.252.227:database=model;username=sa;password=123456' --query 'select * from userinfo where $CONDITIONS'
--target-dir /user/root/example/output-dir/sqoop-from-sqlserver -m 1
--fields-terminated-by "\t" --null-string "**" --null-non-string "##";