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?
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
