如何将mysql表传输到hive?

发布于 2024-10-11 10:02:47 字数 91 浏览 5 评论 0原文

我有一个大型 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的十字路口 2024-10-18 10:02:47
  1. 首先下载mysql-connector-java-5.0.8并将jar放入Sqoop的lib和bin文件夹

  2. 在 Hive 中创建表定义,使用精确的字段名称和类型,与 mysql 中一样

    sqoop import --verbose --fields-termminate-by ',' --connect jdbc:mysql://localhost/test --table 员工 --hive-import --warehouse-dir /user/hive/warehouse --fields-termminate-by ',' --split-by id --hive-table employee

测试 - 数据库名称

员工 - 表名称(测试中存在)

/user/hive/warehouse - HDFS 中数据所在的目录必须导入

--split-by id - id 可以是表 'employee' 的主键

--hive-table employee - 定义存在于 Hive 中的员工表

Sqoop 用户指南(学习 Sqoop 的最佳指南之一)

  1. First of all download mysql-connector-java-5.0.8 and put the jar to lib and bin folder of Sqoop

  2. 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 employee

test - Database name

employee - Table name (present in test)

/user/hive/warehouse - Directory in HDFS where the data has to be imported

--split-by id - id can be the primary key of the table 'employee'

--hive-table employee - employee table whose definition is present in Hive

Sqoop User Guide (One of the best guide for learning Sqoop)

你在我安 2024-10-18 10:02:47

Apache Sqoop 是一个解决这个问题的工具:

Apache Sqoop(TM) 是一款设计用于在 Apache Hadoop 和结构化数据存储(例如关系数据库)之间高效传输批量数据的工具。

Apache Sqoop is a tool that solves this problem:

Apache Sqoop(TM) is a tool designed for efficiently transferring bulk data between Apache Hadoop and structured datastores such as relational databases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文