sqoop1 常用操作说明

1.复制RDBMS表结构到hive

sqoop create-hive-table --connect jdbc:mysql://localhost:3306/databaseName --table tableName  --username username --password userpasswd --hive-table hiveTableName

说明: localhost 为数据库服务器的ip

3306 为数据库访问端口号

databaseName 为访问的数据库名

tableName 为需要映射的RDBMS表名

username 为数据库登录的用户名

userpasswd 为该用户的登录密码

hiveTableName 为映射到hive中的表名

 

2.从RDBMS中导入数据到hive的表中

sqoop import --connect jdbc:mysql://localhost:3306/databaseName --table tableName --username username --password userpasswd --hive-import  --hive-table hiveTableName

 

3.将hive中得表导入到RDBMS中

bin/sqoop export --connect jdbc:mysql://localhost:3306/databaseName --username username --password userpasswd --table hiveTableName --export-dir /home/hive

说明:

--input-fields-terminated-by '#'   指定文件的分隔符

--default-character-set=utf-8      指定字符编码方式

 

posted @ 2014-11-17 16:31  GavinQiu  阅读(322)  评论(0编辑  收藏  举报