sqoop command

1. list the database

 sqoop list-databases --connect jdbc:mysql://192.168.1.9:3306/ -username root -password root;

 

2. list tables in one database

sqoop list-tables --connect jdbc:mysql://192.168.1.9:3306/test -username root -password root;

 

3. import only table structure from mysql to hive

sqoop create-hive-table --connect jdbc:mysql://192.168.1.9:3306/test --table userinfo -username root -password root ot -password root --hive-table hive_userinfo --fields-terminated-by "," --lines-terminated-by "\n";

we'd better identify the path of the table data:

create table hive_userinfo(id int, name string, age int, address string) row format delimited fields terminated by ',' location '/user/hivetest/userinfo';

 

4. import data(many records) from mysql to hive

sqoop import --connect jdbc:mysql://192.168.1.9:3306/test -username root -password root --table userinfo --hive-import --hive-table hive_userinfo -m 2 --fields-terminated-by ",";

-m 2 means use two maps to join the job

 

 5. export data from hdfs to mysql

sqoop export --connect jdbc:mysql://192.168.1.9:3306/test -username root -password root --table userinfo1 --export-dir /user/hivetest/userinfo/part-m-00000 --input-fields-terminated-by ',';

 

 http://www.jb51.net/LINUXjishu/43356.html

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值