是否可以做N-master => MySQL 的 1-slave 复制?

发布于 2024-08-07 21:07:48 字数 113 浏览 5 评论 0 原文

我想制作一台专用的从机,用于三个不同服务器上三个数据库的数据复制。换句话说,我想做Multiple Master =>单从复制。

有没有办法做到这一点,尽可能简单?

谢谢 !

I want to make a dedicated SLAVE machine for data replication of three database on three different servers. In other words, I want to do Multiple Master => SIngle Slave replication.

Is there any way to do this, as simple as it can be ?

Thanks !

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

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

发布评论

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

评论(4

鹤舞 2024-08-14 21:07:48

MySQL 不支持多主复制(一个从站有多个主站)(MySQL Cluster 除外)。您可以对循环(环)复制进行主-主复制(此处此处)。

高性能MySQL第二版作者描述了一种使用主主复制和Blackhole 存储引擎(第 8 章复制 > 复制拓扑 > 自定义复制解决方案> 模拟多主复制 p. “noreferrer">373 - 375)。

它们显示了两种可能的拓扑:

使用两个辅助主机(允许将从机的主机从主机 1 切换到主机 2

  • Master 1: 托管DB1 并从Master 2 复制DB2DB2中所有表的存储引擎均更改为Blackhole,因此数据无法有效存储在Master 1上。
  • Master 2:托管DB2并从Master 1复制DB1DB1中所有表的存储引擎都改为Blackhole,这样数据就不能有效地存储在Master 2
  • Slave 1上: Master 1Master 2复制DB1DB2(允许切换master);结果是从属服务器 1 复制了有效托管在两个不同主服务器上的两个数据库。

使用主链

  • Master 1:仅托管DB1
  • Master 2:托管DB2 > 并从Master 1复制DB1DB1中所有表的存储引擎都改为Blackhole,这样数据就不能有效地存储在Master 2
  • Slave 1上: Master 2复制DB1DB2;结果是从属服务器 1 复制了有效托管在两个不同主服务器上的两个数据库。

请注意,此设置仅允许您通过 Master 1 将更新发送到 DB1,并将 DB2 更新发送到 Master 2 >。您不能将任一表的更新发送给任意主服务器。

也许可以将所描述的解决方案与真正的主主复制(允许更新两个主服务器)结合起来,该复制使用某种自动增量修改,并在 此处

Multi-master replication (a slave with more than one master) is not supported by MySQL (besides MySQL Cluster). You can do a master-master replication of a circular (ring) replication (described here or here).

In High performance MySQL 2nd edition the authors describe a way to emulate multi-master replication using a clever combination of master-master replication and the Blackhole storage engine (Chapter 8 Replication > Replication Topologies > Custom Replication Solutions > Emulating multimaster replication p. 373 - 375).

They show two possibly topologies:

Using two co-masters (allowing to switch the master of the slave from Master 1 to Master 2)

  • Master 1: hosts DB1 and replicates DB2 from Master 2; the storage engine for all tables in DB2 is changed to Blackhole so that the data is not effectively stored on Master 1.
  • Master 2: hosts DB2 and replicates DB1 from Master 1; the storage engine for all tables in DB1 is changed to Blackhole so that the data is not effectively stored on Master 2
  • Slave 1: replicates DB1 and DB2 from either Master 1 or Master 2 (allowing to switch masters); the result is that Slave 1 replicates both databases that are effectively hosted on two different masters.

Using a master-chain

  • Master 1: only hosts DB1
  • Master 2: hosts DB2 and replicates DB1 from Master 1; the storage engine for all tables in DB1 is changed to Blackhole so that the data is not effectively stored on Master 2
  • Slave 1: replicates DB1 and DB2 from Master 2; the result is that Slave 1 replicates both databases that are effectively hosted on two different masters.

Please note that this setup only allows you to send updates to DB1 through Master 1 and updates to DB2 to Master 2. You cannot send updates to either table to arbitrary masters.

Pehaps it's possible to combine the described solution with the hack for a true master-master replication (allowing updates to both masters) that uses some sort of autoincrement-mangling and is described here or here.

绿光 2024-08-14 21:07:48

据我所知不可能。

然而,如果这里的要求只是拥有一个基于复制的备份机器,那么您可以轻松地运行三个 MySQL 服务器(在不同的地址和/或端口上) - 我们在这里这样做,有两个复制环,每个复制环都包含我们的-house 临时服务器作为节点。

一个非常规的想法,如果您确实希望将所有数据放入一台服务器中,并且表模式要么是固定的,要么是静态的并且在您的控制之下:设置一台服务器并打开三个数据库并链接所有数据库使用联合引擎的表。理论上(需要注意的是:我从来没有尝试过!),然后您可以将这些联合表复制到第二台服务器上(同样,可能在同一台机器上),从而为您提供单个 MySQL 上数据的真实实时副本实例。你甚至可以尝试再次复制回来,但那样可能会变得疯狂:)

No way that I'm aware of.

However, if the requirement here is simply to have a single replication-based backup machine, you can easily enough run three MySQL servers (on different addresses and/or ports) - we do that here, with two replication rings that each include our in-house staging server as a node.

An off-the-wall idea, if you really do want all the data into a single server and the table schemas are either fixed, or pretty much static and under your control: set up one server with the three databases on and link all the tables using the federated engine. In theory (huge caveat: I've never tried it!), you can then replicate off those federated tables on to a second server (again, possibly on the same machine), giving you genuine live copies of the data on a single MySQL instance. You could even try replicating back again, but that way possibly lies madness :)

夏有森光若流苏 2024-08-14 21:07:48

我对 MySQL 不太了解,但是您是否可以设置“仅上传”复制配置,其中主服务器/发布服务器的角色仅收集在从服务器/订阅服务器级别进行的更新。

I do not know a lot about MySQL, but don't you have the possibility to set an 'upload only' replication configuration, where the role of the master/publisher is only to collect updates made at the slave/subscriber level.

鸠魁 2024-08-14 21:07:48

可能值得一看 maatkit 的表同步 - 它不是“真正的”复制,但它可能已经足够好了。

Might be worth a look at maatkit's table sync -- it's not "real" replication but it might be good enough.

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