Home > Database > Mysql Tutorial > body text

Sqoop数据导出导入命令

WBOY
Release: 2016-06-07 14:59:14
Original
1388 people have browsed it

1. 将mysql中的数据导入到hive中 sqoop import --connect jdbc:mysql://localhost:3306/sqoop --direct --username root --passw

1. 将mysql中的数据导入到hive中

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版本的就没有问题了

相关阅读:

通过Sqoop实现Mysql / Oracle 与HDFS / Hbase互导数据

[Hadoop] Sqoop安装过程详解

用Sqoop进行MySQL和HDFS系统间的数据互导

Hadoop Oozie学习笔记 Oozie不支持Sqoop问题解决

Hadoop生态系统搭建(hadoop hive hbase zookeeper oozie Sqoop)

Hadoop学习全程记录——使用Sqoop将MySQL中数据导入到Hive中

Sqoop 的详细介绍:请点这里
Sqoop 的下载地址:请点这里

本文永久更新链接地址

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template