是否可以做N-master => MySQL 的 1-slave 复制?
我想制作一台专用的从机,用于三个不同服务器上三个数据库的数据复制。换句话说,我想做Multiple Master =>单从复制。
有没有办法做到这一点,尽可能简单?
谢谢 !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想制作一台专用的从机,用于三个不同服务器上三个数据库的数据复制。换句话说,我想做Multiple Master =>单从复制。
有没有办法做到这一点,尽可能简单?
谢谢 !
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
MySQL 不支持多主复制(一个从站有多个主站)(MySQL Cluster 除外)。您可以对循环(环)复制进行主-主复制(此处或此处)。
在高性能MySQL第二版作者描述了一种使用主主复制和
Blackhole
存储引擎(第 8 章复制 > 复制拓扑 > 自定义复制解决方案> 模拟多主复制 p. “noreferrer">373 - 375)。它们显示了两种可能的拓扑:
使用两个辅助主机(允许将从机的主机从主机 1 切换到主机 2)
Blackhole
,因此数据无法有效存储在Master 1上。Blackhole
,这样数据就不能有效地存储在Master 2使用主链
Blackhole
,这样数据就不能有效地存储在Master 2请注意,此设置仅允许您通过 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)
Blackhole
so that the data is not effectively stored on Master 1.Blackhole
so that the data is not effectively stored on Master 2Using a master-chain
Blackhole
so that the data is not effectively stored on Master 2Please 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.
据我所知不可能。
然而,如果这里的要求只是拥有一个基于复制的备份机器,那么您可以轻松地运行三个 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 :)
我对 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.
可能值得一看 maatkit 的表同步 - 它不是“真正的”复制,但它可能已经足够好了。
Might be worth a look at maatkit's table sync -- it's not "real" replication but it might be good enough.