How to transfer mysql table to hive?(如何将mysql表转移到hive?)
问题描述
我有一个很大的 mysql 表,我想将它转移到一个 Hadoop/Hive 表.是否有标准命令或技术可以将简单(但很大)的表从 Mysql 传输到 Hive?该表主要存储分析数据.
I have a large mysql table that I would like to transfer to a Hadoop/Hive table. Are there standard commands or techniques to transfer a simple (but large) table from Mysql to Hive? The table stores mostly analytics data.
推荐答案
首先下载mysql-connector-java-5.0.8,把jar包放到Sqoop的lib和bin文件夹
First of all download mysql-connector-java-5.0.8 and put the jar to lib and bin folder of Sqoop
在 Hive 中创建表定义,使用 确切的字段名称和类型,就像在 mysql 中一样
Create the table definition in Hive with exact field names and types as in mysql
sqoop import --verbose --fields-terminated-by ',' --connect jdbc:mysql://localhost/test --table employee --hive-import --warehouse-dir/user/hive/warehouse--fields-terminated-by ',' --split-by id --hive-table 员工
sqoop import --verbose --fields-terminated-by ',' --connect jdbc:mysql://localhost/test --table employee --hive-import --warehouse-dir /user/hive/warehouse --fields-terminated-by ',' --split-by id --hive-table employee
测试 - 数据库名称
employee - 表名(存在于测试中)
employee - Table name (present in test)
/user/hive/warehouse - HDFS 中需要导入数据的目录
/user/hive/warehouse - Directory in HDFS where the data has to be imported
--split-by id - id可以是'employee'表的主键
--split-by id - id can be the primary key of the table 'employee'
--hive-table employee - 其定义存在于 Hive 中的雇员表
--hive-table employee - employee table whose definition is present in Hive
Sqoop 用户指南(学习 Sqoop 的最佳指南之一)
Sqoop User Guide (One of the best guide for learning Sqoop)
这篇关于如何将mysql表转移到hive?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将mysql表转移到hive?


- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01