简体   繁体   English

从 mysql 到 mongo db 的数据调度问题

[英]issue in data scheduling from mysql to mongo db

We are developing a SAAS system in which we have initially used MySQL as DB but as data grows our listings of data get slower so to resolve that we had used Mongo DB in which we had stored the prepared JSON we need to display (with all the join of MySQL) for some time it works well我们正在开发一个 SAAS 系统,其中我们最初使用 MySQL 作为数据库,但随着数据的增长,我们的数据列表变得更慢,因此我们使用了 Mongo DB,其中存储了我们需要显示的准备好的 JSON(包含所有加入 MySQL) 一段时间它运行良好

we have written a scheduler in java which runs in every 2 mins and update the modified records from MySQL to mongo我们用 java 编写了一个调度程序,它每 2 分钟运行一次,并将修改后的记录从 MySQL 更新到 mongo

Initially, it works well but as time goes and data and its rate increases it fails many times so we decided to find any alternative for that which can read from MySQL binlogs and we can merge MySQL tables according to our need on the way and store in Mongo DB最初,它运行良好,但随着时间的推移和数据及其速率的增加,它失败了很多次,所以我们决定找到任何可以从 MySQL 二进制日志中读取的替代方案,我们可以在途中根据需要合并 MySQL 表并存储在蒙戈数据库

Table 1
  Col11
  Col12
  Col13
  Col14
  Col15

Table 2 Col21 Col22 Col23 Col24 Col25表 2 Col21 Col22 Col23 Col24 Col25

Mongo Collection蒙戈系列

  Col11
  Col12
  Col13
  Col14
  Col15 
  Col21
  Col22
  Col23
  Col24
  Col25

One option could be Kafka Connect for moving data from MySQL to Kafka and then from Kafka to your MongoDB.一种选择可能是Kafka Connect,用于将数据从 MySQL 移动到 Kafka,然后从 Kafka 移动到您的 MongoDB。

Step 1: Use JDBCSourceConnector to move data from MySQL to Kafka第 1 步:使用JDBCSourceConnector将数据从 MySQL 移动到 Kafka

The Kafka Connect JDBC source connector allows you to import data from any relational database with a JDBC driver into Apache Kafka® topics. Kafka Connect JDBC 源连接器允许您使用 JDBC 驱动程序将数据从任何关系数据库导入到 Apache Kafka® 主题中。

Step 2: Use MongoDB Connector to move data from Kafka to MongoDB第 2 步:使用MongoDB Connector将数据从 Kafka 移动到 MongoDB

Map and persist events from Kafka topics directly to MongoDB collections with ease.轻松地将 Kafka 主题中的事件直接映射并持久化到 MongoDB 集合。 Ingest events from your Kakfa topics directly into MongoDB collections, exposing the data to your services for efficient querying, enrichment, and analytics.将您的 Kakfa 主题中的事件直接摄取到 MongoDB 集合中,将数据公开给您的服务以进行高效查询、扩充和分析。

Note that MongoDB connector can be used as source or sink connector.请注意,MongoDB 连接器可用作源连接器或接收器连接器。 In your case, you'd need the sink connector, for moving data from your Kafka topic(s) to your target table(s) in MongoDB.在您的情况下,您需要接收器连接器,用于将数据从 Kafka 主题移动到 MongoDB 中的目标表。

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

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