hive sqoop,sqoop-hive import data

 

https://segmentfault.com/a/1190000002532293

https://www.zybuluo.com/aitanjupt/note/209968

 

create table dep(id int,name string) row format delimited fields terminated by '\t';


11 sssssssss
22 ttttttttt
33 vvvvvvvvv


load data local inpath '/opt/people.txt' into table hive.dep;

 

mysql -uroot -proot

use metastore;
select * from TBLS where TBL_NAME='dep';


hive -e "select * from hive.dep limit 3"


hdfs dfs -ls /


sqoop import --connect jdbc:mysql://127.0.0.1:3306/metastore --username root --password root --table TBLS

测试MySQL连接
sqoop list-databases --connect jdbc:mysql://127.0.0.1:3306/mysql --username root --password root

检验SQL语句

sqoop eval --connect jdbc:mysql://ucampus-test.cmtmrzrxlu53.rds.cn-northwest-1.amazonaws.com.cn:3306/ucampus --username ucauser --password 'Key!go003' --query "SELECT * from base_course"


sqoop import --connect jdbc:mysql://ucampus-test.cmtmrzrxlu53.rds.cn-northwest-1.amazonaws.com.cn:3306/ucampus --username ucauser --password 'Key!go003' --query "SELECT * from stu_student where sch_id=4 AND $CONDITIONS" --split-by date --target-dir /user/hive/warehouse/anqi_wang


--fields-terminated-by "\t" --lines-terminated-by "\n" -m 1 --hive-import --hive-overwrite --create-hive-table --hive-table book --delete-target-dir


sqoop import --connect jdbc:mysql://localhost:3306/sqoop
--username root
-P
--split-by id
--columns id,name
--table customer
--target-dir /user/cloudera/ingest/raw/customers
--fields-terminated-by ","
--hive-import
--create-hive-table
--hive-table sqoop_workspace.customers


sqoop import --connect jdbc:mysql://ucampus-test.cmtmrzrxlu53.rds.cn-northwest-1.amazonaws.com.cn:3306/ucampus --username ucauser --password 'Key!go003' ---driver com.mysql.jdbc.Driver --split-by id --columns id,name --table stu_student --target-dir /user/hive/warehouse/hive/dep --fields-terminated-by "," --hive-import --create-hive-table --hive-table hive.dep

cd /usr/lib/sqoop/lib/
yum install unzip
wget http://www.java2s.com/Code/JarDownload/java-json/java-json.jar.zip
unzip java-json.jar.zip

cp /usr/lib/hive/lib/hive-common-1.1.0-cdh5.9.1.jar /usr/lib/sqoop/lib/
cp /usr/lib/hive/lib/hive-shims-*.jar /usr/lib/sqoop/lib

 

sqoop import --connect jdbc:mysql://ucampus-test.cmtmrzrxlu53.rds.cn-northwest-1.amazonaws.com.cn:3306/ucampus --username ucauser --password 'Key!go003' --driver com.mysql.jdbc.Driver --split-by id --columns id,name --table stu_student --target-dir /user/hive/warehouse/hive/dep3 --fields-terminated-by "," --hive-import --create-hive-table --hive-table hive.dep3

转载于:https://www.cnblogs.com/SZLLQ2000/p/10709770.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值