MySQL 数据库多表复制
以前,我有过进行以下数据库复制的经验。
(1) 我在机器 A 的 1 个数据库中有 2 个表
(2) 我更新机器 A 中的 2 个表
(3) 机器 A 将把 2 个表复制到机器 B。机器 B 也将在 1 个数据库中包含 2 个表。
现在,我想完成以下任务:
(1)我有表A,在机器A的1个数据库内。
(2)我有表B,在机器B的1个数据库内。
(3)我想复制表A (4) 机器 C 将在一个数据库内拥有表A
和表 B。
是否可以通过数据库复制来实现这一点?
Previously, I have experience in doing the following database replication.
(1) I have 2 tables within 1 database in Machine A
(2) I update 2 tables in Machine A
(3) Machine A will replicate 2 tables to Machine B. Machine B will also contain 2 tables within 1 database.
Now, I would like to accomplish the following :
(1) I have Table A, within 1 database in Machine A.
(2) I have Table B, within 1 database in Machine B.
(3) I would like to replicate Table A and Table B to Machine C.
(4) Machine C will have Table A and Table B, within ONE database.
Is it possible this to be accomplished, through database replication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,每个 mysql 服务器只能有 Master。因此,例如,您可以在机器 C 上的不同端口上运行两个单独的 mysql 实例,分别从属于机器 A 和机器 B,但不能同时从一台服务器上运行。
根据您的情况,这样做可能会让您足够接近一些其他复制技术(例如定期使用 mysqldump 在机器 C 上复制一个表)可以工作。这仅取决于您对从站的需求(表有多大(即通过非从属方法复制它们的速度有多快),过时的程度是可以接受的,您是否真的需要它们在一个数据库中还是一个数据库中服务器足够好等等)。
经过再三思考,有一种类型的多主复制是可能的,如果您只想将数据存储在一个数据库中并且并不真正需要机器 C,那么它可能会满足您的需求。在这种情况下,您实际上可以拥有以下之一一台服务器作为表 A 的主服务器,作为表 B 的从服务器,而另一台服务器作为表 B 的主服务器(如果需要,也可以作为表 A 的从服务器)。看起来不错的解释。
Unfortunately, you can have only Master per mysql server. So for instance you could run two separate instances of mysql on different ports on Machine C that slaved from Machine A and Machine B respectively, but not from both in one server.
Depending on your situation, doing that might be get you close enough that some other replication technique (like periodically using mysqldump to copy one table across on Machine C) would work. It would just depend on your needs for the slaves (how big are the tables (i.e. how quickly can they be copied via a non-slaving method), how out of date is acceptable, do you really need them in one DB or is one server good enough, etc).
After a second thought, there is one type of multi-master replication which is possible and might serve your needs if you just want the data in one DB and don't really need Machine C. In that case, you could actually have one of the servers be the Master for Table A and Slave for Table B, while the other is Master for Table B (and if necessary, Slave for Table A). Decent looking explanation.
除非您使用集群,否则多主复制实际上是不可能的,那么我认为您不能使用您所讨论的示例,除非这两个表实际上是相同的数据,只是单独的分区。
Multi-master replication isn't really possible unless your using Cluster, then I don't think you can use the example your talking about unless the two tables are really the same data simply seperate partitions.