[sqoop] sqoop 小试牛刀

 

 

sqoop 1.4.6  小试牛刀

 sqoop import 参数

 

1. mysql导入 到hdfs中

./sqoop import --connect jdbc:mysql://mysql:3306/part --username root --password 123456 --table big_hdfs -m 1 --target-dir /sqoop/import/mysql/

 

 

2. mysql 导入 到 hive 指定库 中

./sqoop import --hive-import --connect jdbc:mysql://mysql:3306/part --username root --password 123456 --table big_hdfs -m 1 --hive-database udata

 

 

3. mysql 结果集 导入 到指定hive表中

where 条件中加上 $CONDITIONS 就可以了

./sqoop import --hive-import --connect jdbc:mysql://mysql:3306/part --username root --password 123456 -m 1 --query 'select id,name,htime from big_hdfs where id<=6 and $CONDITIONS' --target-dir '/sqoop1/import/mysql' --hive-table mysql_import_hdfs

 

 

 4. hdfs 导出到mysql中

./sqoop export --connect jdbc:mysql://mysql:3306/part --username root --password 123456  --table big_person -m 1 --export-dir '/hive/warehouse/test1.db/com_inner_person/person.data'

mysql中的表要提前建好,否则抛出异常。

 

如下信息,导入成功

 hdfs中的数据

导入的数据

 

 

参考:

http://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html#_introduction

posted @ 2017-06-26 10:52  snow__wolf  阅读(245)  评论(0编辑  收藏  举报