常用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'

 

posted @ 2018-05-14 18:58  硅谷工具人  阅读(299)  评论(0编辑  收藏  举报
成功之道,在于每个人生阶段都要有不同的目标,并且通过努力实现自己的目标,毕竟人生不过百年! 所有奋斗的意义在于为个人目标实现和提升家庭幸福,同时能推进社会进步和国家目标! 正如古人讲的正心诚意格物致知,修身齐家治国平天下。