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

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先下载mysql-connector-java-5.0.8并将jar放入Sqoop的lib和bin文件夹
在 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 的最佳指南之一)
First of all download mysql-connector-java-5.0.8 and put the jar to lib and bin folder of Sqoop
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)
Apache Sqoop 是一个解决这个问题的工具:
Apache Sqoop is a tool that solves this problem: