MySQL单从多主复制
我需要将不同 MySQL 数据库从多个服务器复制到单个从服务器中。这怎么能做到呢?我是否需要在从属服务器上为每个主服务器提供单独的 MySQL 实例?或者有没有办法定义多个master主机?
我们基本上使用从站作为多个网站的热备份。我们应该考虑集群而不是复制吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实现这一目标的最佳方法是一个真正的备份解决方案......但是当您按照您描述的方式为每个主设备定义一个从属实例时,您可以保持灵活性,例如,如果需要任何更改,您甚至可以移动一个或多个将从属实例转移到另一台机器,而不会对其他从属/主控产生任何影响...
编辑 - 根据评论:
有关如何在同一台机器上设置多个 MySQL 实例的说明参见示例
这使您足够灵活,可以拥有并行不同的 MySQL 版本(每个从/主组合相同)...
Best way to achieve that would be a real backup solution... but when you do it the way you describe define one slave instance per master - this way you stay flexible, for example if any change is needed you could even move one or more of the slave instances to another machine without any influence on the other slaves/masters...
EDIT - as per comments:
For a description on how to setup multiple instances of MySQL on the same machine see for example
This keeps you even flexible enough to have different MySQL versions in parallel (identical per slave/master combination)...
2011年以来,环境发生了一些变化。 MySQL 5.7 和 MariaDB 10 现在支持从多个主服务器进行复制 - 但它们使用的语法略有不同。
MySQL 5.7: http://www .percona.com/blog/2013/10/02/mysql-5-7-multi-source-replication/
MariaDB 10:https://mariadb.com/ kb/en/mariadb/documentation/managing-mariadb/replication/standard-replication/multi-source-replication/
Since 2011 the environment has changed a bit. Replication from multiple masters is now supported in MySQL 5.7 and MariaDB 10 - but they use slightly different syntax.
MySQL 5.7: http://www.percona.com/blog/2013/10/02/mysql-5-7-multi-source-replication/
MariaDB 10: https://mariadb.com/kb/en/mariadb/documentation/managing-mariadb/replication/standard-replication/multi-source-replication/
您将必须使用 mysql 的多个实例。如果你有6个master并且你试图将所有slave放在一台物理机器上,你将需要6个实例,
假设您使用某种风格的 unix 操作系统,您可以设置一个 cron 作业来停止和启动每个实例,以将平均负载保持在最低水平。
在进行热备份之前,最好让一个从实例运行并赶上其主实例。相同的步骤将适用于下一个从属设备,依此类推。每次启动一个从属实例时,您都可以关闭其他 mysql 从属实例以保持平均负载。降到最低限度。
You will have to use multiple instances of mysql. If you are having 6 masters and you are trying to put all the slaves on one physical machine, you will need 6 instances,
Assuming you are using some flavour of unix OS, you could set up a cron job to stop and start each instance to keep the load average to a minimum.
It would be good to let one slave instance run and catch up with its master before doing hot backup. The same steps would apply to next slave and so on. Each time you start up a slave instance you shutdown the other mysql slave instances can be shutdown to keep load avg. to a minimum.