如何复制两个不同的数据库系统?

发布于 2024-08-17 04:17:59 字数 471 浏览 5 评论 0原文

我不确定它是否完全适合 stackoverflow,但是由于我正在寻找一些代码而不是工具,我认为它确实适合。

我正在寻找一种如何复制/同步不同数据库系统的方法——在本例中:mysql 和 mongodb。我们出于不同的目的而运行两者。我们从 mysql 数据库开始,后来为特殊应用添加了 mongodb。我们希望在两个数据库中都有数据,我们希望分别在 mysql 和 mongodb 中的 dbrefs 中都有约束。例如:我们需要 mysql 中的用户记录,但也需要 mongodb 中的表对象之间的引用。目前我们有一个 cronjob,它转储 mysql 数据并将其导入到 mongodb 中。然而,尽管它工作得很好,但这不是我们想要的解决方案。

我认为目前单向复制就足够了——mysql->mongodb,重要的是,复制是“实时”工作的,就像mysql主->从复制工作一样。

是否已经有针对此问题的解决方案或任何人关于如何实现此目标的想法?

谢谢!

I'm not sure, if it fits exactly stackoverflow, however as i'm seeking for some code rather than a tool, i think it does.

I'm looking for a way of how to replicate / synchronize different database systems -- in this case: mysql and mongodb. We are running both for different purpose. We started with a mysql database and added mongodb later on for special applications. There's data we would like to have in both databases, where we want to have constraints in mysql respectivly dbrefs in mongodb. For example: We need a user-record in mysql, but also in mongodb for references between tables respectivly objects. At the moment we have a cronjob, which dumps the mysql data and imports it in mongodb. However though it works quite well, that's not the solution we would like to have.

I think for the moment a one-way replication would be enough -- mysql->mongodb, the important part is, that the replication works in "realtime", much like a mysql master->slave replication works.

Are there already any solutions for this problem or ideas anyone of how to achieve this?

Thanks!

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

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

发布评论

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

评论(4

独夜无伴 2024-08-24 04:17:59

SymmetricDS 是一款开源、基于 Java、支持 Web、独立于数据库的数据同步/复制软件,可以实现这一点经过一些调整。它有一个名为 IDataLoaderFilter 的扩展点,您可以使用它来实现 MongodbDataLoader。

这将有助于单向数据库复制。从 MongoDb 同步可能会有点困难 ->关系数据库,但 SymmetricDS 团队将非常有助于寻找解决方案。

SymmetricDS is open source, Java-based, web-enabled, database independent, data synchronization/replication software that might do the trick with a few tweaks. It has an extension point called IDataLoaderFilter which you could use to implement a MongodbDataLoader.

This would help with one way database replication. It might be a little more difficult to synchronized from MongoDb -> relational database, but the SymmetricDS team would be very helpful in trying to find the solution.

哆啦不做梦 2024-08-24 04:17:59

您正在寻找的称为 EAI(企业应用程序集成)。周围有很多商业工具,但在提供的链接下,您还可以找到一些 OSS 解决方案。 EAI的基础是你有数据源和数据汇。 EAI 框架提供了在两者之间构建自定义泵的工具。

我建议使用数据库触发器来启动同步或在应用程序中发送触发信号。请注意,不存在关键孔解决方案,因为同步可能变得任意复杂(例如,如何确保复制所有行?)。

What you're looking for is called EAI (Enterprise application integration). There are a lot of commercial tools around but under the provided link, you'll also find a couple OSS solutions. The basis of EAI is that you have data sources and data sinks. The EAI framework offers tools to build custom pumps between the two.

I suggest to either use a DB trigger to start the synchronization or send a trigger signal in your applications. Note that there is no key-hole solution since synchronization can become arbitrarily complex (for example, how do you make sure that all rows are copied?).

奶茶白久 2024-08-24 04:17:59

据我所知,您需要开发某种“控制程序”,其中包含每个 DBMS 的驱动程序并将其作为守护程序运行。守护进程应该有一个触发器或一个非常小的重新检查间隔以保持数据库同步

As far as I see you need to develop some sort of "Control program" that has the drivers for each DBMS and run it as a daemon. The daemon should have a trigger or a very small recheck interval to keep the DBs synchronized

迷鸟归林 2024-08-24 04:17:59

从技术上讲,您可以设置一个进程来解析 MySQL 服务器的二进制日志并复制相关的 sql 查询。我从来没有用不同的数据库作为从属做过这样的事情,但也许值得一试?

Technically, you could set up a process which parses the binary log of the MySQL server and replicate the relevant sql queries. I've never done such a thing with a a different database as a slave, but maybe it is worth a shot?

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