MySQL从不同的Master复制不同的数据库
我对 MySQL 复制还比较陌生。简而言之,我在 3 台 Ubuntu Lucid Lynx 服务器上有一个 MySQL 5.1 服务器实例。
ATM 我有服务器 A(主),它将单个数据库复制到服务器 C(从)。
这已经运行了几个月,没有出现任何问题。
我现在想让服务器 B(作为主服务器)将不同的单个数据库复制到服务器 C(从服务器)。
我正在考虑实现这一点,但我最初的阅读似乎表明复制从属服务器不能有两个主服务器。
我的问题是,即使只复制单个或选择的数据库也是如此吗?
请记住,我不希望从不同的主数据库复制相同的数据库。我只是希望从单独的主服务器在单个服务器上复制多个单独的数据库。
I'm relatively new to MySQL replication. In a nutshell I have a MySQL 5.1 server instance on 3 Ubuntu Lucid Lynx servers.
ATM I have Server A (MASTER) which replicates a single database to Server C (SLAVE).
This has been running for a couple months without a problem.
I now want to have Server B (as MASTER) replicate a different single database to Server C (SLAVE).
I was looking into implementing this, but my initial reading seems to indicate that a replication slave server can't have two masters.
My question is, is this the case even when only single or select database are being replicated?
Keep in mind I do not wish to replicate the same database from different masters. I simply wish to replicate multiple separate database on a single server, from separate masters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 MySQL 中为每个数据库设置不同的主数据库。
《高性能 MySQL》一书用完整的章节讨论了这个问题。我建议您获取一份副本并使用其中的信息。
http://oreilly.com/catalog/9780596101718/
您可以阅读相关章节的副本在线这里:
http://oreilly.com/catalog/hpmysql/chapter/ch07.pdf
这是第一版的内容,第二版更新了,但是涉及复制的第 8 章无法在线免费获取。
更新
我正在谈论的解决方案仅在本书的第二版中,请参阅对一个类似问题的回答:是否可以做N-master => MySQL 的 1-slave 复制?
You can set a different master per database in MySQL.
The book
high performance MySQL
has a full chapter on this issue. I recommend getting hold of a copy and using the info in that.http://oreilly.com/catalog/9780596101718/
You can read a copy of the relevant chapter online here:
http://oreilly.com/catalog/hpmysql/chapter/ch07.pdf
This is from the first edition, the second edition is more up to date, but chapter 8, which deals with replication is not freely available online.
UPDATE
The solution I'm talking about is only in the 2nd edition of the book, see this answer to a simular question: Is it possible to do N-master => 1-slave replication with MySQL?
一般来说,你不能这样做。您无法进行多对一复制(可以进行一对多复制)。
此外,您实际上不能只复制一个数据库 - 基于语句模式的跨数据库更新然后变得不可复制,这意味着一旦有人在主服务器上执行更新,您的从服务器就会失败(或变得不同步)。
标准解决方案是安装多个 mysql 实例,这远非理想,但可行。
In general you can't do this. You can't replicate from many-to-one (you can from one-to-many).
Also you can't really just replicate one database - cross-database updates in statement-based mode then become unreplicatable, which means your slave will fail (or become out of sync) as soon as someone does one on the master.
The standard solution is to install multiple mysql instances, which is far from ideal, but works.