常用sqoop操作

Posted 胖子学习天地

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了常用sqoop操作相关的知识,希望对你有一定的参考价值。

1. 关系型数据库到hive

sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table base_dorm --hive-table base_dorm --hive-import  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table h_59_dormentrydorm --hive-table h_59_dormentrydorm --hive-import  
sqoop import --connect jdbc:mysql://localhost:3306/logdata --username datahs --password datahs2015 --table wechat_trace --hive-database 59store --hive-table wechat_trace --hive-import --split-by ip  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table base_food --hive-database 59store --hive-table base_food_1103 --hive-import --split-by order_id  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table base_dorm_sal --hive-table base_dorm_sal --hive-import -m 1  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --query ‘select a.order_id,a.order_mo,a.order_amount,a.order_date,a.city_desc,a.city_staff_name,a.dorm_name,b.dorm_price from base_order a left join base_food b on a.order_id=b.order_id  WHERE $CONDITIONS‘  --target-dir /alidata/query1 --split-by a.order_id  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table base_dh_stock --hive-database 59store --hive-table base_dh_stock --hive-import --split-by dhid  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table base_site_man --columns ‘city_staff,zone_staff‘ --create-hive-table -target-dir /hive/spark/warehouse/59store.db/base_site_man2 -m 1 --hive-table base_site_man2 --hive-import -- --default-character-set=utf-8  
sqoop import --connect jdbc:mysql://localhost:3306/datahouse --username datahs --password datahs2015 --table base_site_man --columns ‘city_staff,zone_staff‘ --create-hive-table -m 1 --hive-table base_site_man3 --hive-import -- --default-character-set=utf-8  

 

2. hive到关系型数据库

sqoop export --connect jdbc:mysql://localhost:3306/logdata --username datahs --password datahs2015 --table base_dh_stock --export-dir /user/hive/warehouse/test.db/base_dh_stock --input-fields-terminated-by ‘\001‘

 

以上是关于常用sqoop操作的主要内容,如果未能解决你的问题,请参考以下文章

ETL工具sqoop

提效小技巧——记录那些不常用的代码片段

[sqoop]sqoop入门-下载安装运行和常用命令

C#程序员经常用到的10个实用代码片段 - 操作系统

Sqoop的安装及常用命令

sqoop的常用命令