Sqoop导入导出命令集

来源:互联网 发布:linux无法解压zip 编辑:程序博客网 时间:2024/06/05 20:02

1、从hdfs上把数据导出到关系型数据库(mysql)

sqoop export --connect jdbc:mysql://MysqlIPAddress:3306/recommendation --username root --password 123456 --table recommendation --export-dir hdfs://NamenodeIPAdress:8020/output/result/ --input-fields-terminated-by '\t'

注意:input-fields-terminated-by是指HDFS上的文件导出的时候以什么作为分隔符,这里是以\t作为分隔符,注意‘  '不认识

2 、从oracle导入到hdfs

在linux命令模式下运行sqoop脚本:sqoop --options-file ./test_imp.opt
test_imp.opt脚本内容如下:
import --connectjdbc:oracle:thin:@192.168.1.101:1522/myora--username beifeng--password 123-m1--null-string''--table CITY--columns "ID,CITY_CNAME,PROVINCE_ID"--target-dir/user/hadoop/city



 

0 0
原创粉丝点击