简体   繁体   English

多个mysql表中的数据到hadoop map-reduce

[英]data from mutiple mysql tables to hadoop map-reduce

We have following scenario: 我们有以下情形:

We have a chain of map-reduce processes implemented in java.Currently we are reading data from a mysql table and saving output to another mysql table .Now we may need data from another table as input to map/reduce process. 我们有一系列用Java实现的map-reduce processes 。当前我们正在从mysql表读取数据并将输出保存到另一个mysql table 。现在我们可能需要来自另一个表的数据作为map / reduce进程的输入。

Possible Solutions: 可能的解决方案:

a) Either we can have a join query for input to map process or a)我们可以有一个联接查询以输入到映射过程,或者

b) we can read needed data by making simple jdbc connection and requesting data again and again(although, i don't prefer it). b)我们可以通过建立简单的jdbc connection并一次又一次地请求数据来读取所需的数据(尽管我不喜欢它)。

Questions: 问题:

What are the best practices in such scenario? 在这种情况下的最佳做法是什么? We may move to mongoDB in future.What will be best practice in that scenario? 我们mongoDB可能会迁移到mongoDB 。在这种情况下,最佳做法是什么?

我认为目前不可能。

SQOOP and HIVE can be used. 可以使用SQOOPHIVE

You can use SQOOP for transfering data from mysql table to HDFS and then to HIVE . 您可以使用SQOOP将数据从mysql表传输到HDFS,然后传输到HIVE From HIVE (after operations) , you can export the tables back to Mysql. 从HIVE(操作后),您可以将表导出回Mysql。

Example : 范例:

  • First of all download mysql-connector-java-5.0.8 and put the jar to lib and bin folder of Sqoop 首先下载mysql-connector-java-5.0.8并将jar放到Sqoop的lib和bin文件夹中
  • Create the table definition in Hive with exact field names and types as in mysql 在Hive中创建表定义,并使用与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 sqoop import --verbose --fields-terminate-by','--connect jdbc:mysql:// localhost / test --table employee --hive-import --warehouse-dir / user / hive / warehouse --fields -以','结尾-以id为分隔-hive-table员工

Follow this Link for reference 请点击此链接以供参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM