sqoop数据导出导入命令
2015-09-11 13:22
381 查看
1. 将mysql中的数据导入到hive中
其中--table tb1是mysql sqoop数据库中的一张表,--hive-table tb1是导入到hive中该表的名字,不需要事先建表。
2. 将hive中的数据导入到mysql中
--table t4是导入到mysql中表的名字,需要事先建表
3. 将mysql中的数据导入到hdfs中
4. 将hdfs中的数据导入到mysql中
同样需先在mysql中建立tb1表
在用sqoop将mysql中的数据导入到hdfs中,曾报以下错误:
经查询,为mysql JDBC驱动bug所致,我用的是mysql-connector-java-5.1.10-bin.jar版本的,后改为mysql-connector-java-5.1.25-bin.jar版本的就没有问题了
sqoop import --connect jdbc:mysql://localhost:3306/sqoop --direct --username root --password 123456 --table tb1 --hive-table tb1 --hive-import -m 1
其中--table tb1是mysql sqoop数据库中的一张表,--hive-table tb1是导入到hive中该表的名字,不需要事先建表。
2. 将hive中的数据导入到mysql中
sqoop export --connect jdbc:mysql://localhost:3306/sqoop --username root --password 123456 --direct --table t4 --export-dir /user/hive/warehouse/tb1/part-m-00000 --input-fields-terminated-by '\001'
--table t4是导入到mysql中表的名字,需要事先建表
3. 将mysql中的数据导入到hdfs中
sqoop import --connect jdbc:mysql://localhost:3306/sqoop --direct --username root --password 123456 --table tb1 -m 1
4. 将hdfs中的数据导入到mysql中
sqoop export --connect jdbc:mysql://localhost:3306/sqoop --direct --table tb1 --username root --password 123456 --export-dir hdfs://localhost:9000/user/hadoop/tb1/part-m-00000 -m 1
同样需先在mysql中建立tb1表
在用sqoop将mysql中的数据导入到hdfs中,曾报以下错误:
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@54b0a583 is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.
经查询,为mysql JDBC驱动bug所致,我用的是mysql-connector-java-5.1.10-bin.jar版本的,后改为mysql-connector-java-5.1.25-bin.jar版本的就没有问题了
相关文章推荐
- Linux Shell 脚本中字符串的连接方法
- Zabbix---添加linux服务器监控
- Redhat 6.4-x64 编译 Hadoop-2.7.1并分布式安装
- linux中sed的用法
- LAMP基础环境的搭建,即Linux、Apache、MySQL、PHP环境
- linux下各种变量的理解
- linux 下 读取某个文件的某一行或者某几行
- opengl介绍 webGL Open Inventor、Cosmo3D、Optimizer 3DLabs
- redhat 6.5 使用其它Linux镜像源的yum源
- 国外知名的技术网站、社区
- openfire中开发带servlet的插件并实现免认证访问
- Openmesh函数库设计及与CGAL的对比
- 29个你必须知道的Linux命令
- elicpse之tomcat配置
- 新建tomcat的server服务,在左侧项目浏览处,右键空白的地方,选择new,再选择other选项
- VS2010下配置Openmesh+openGL29
- linux下简易socket编程
- Linux下软件常见安装方式
- 如何更改linux文件的拥有者及用户组(chown和chgrp)--- chown root:root testfile // 使用 chown 一次性修改拥有者及组
- Nginx和LVS概述