MySQL单从多主复制

发布于 2024-12-06 12:07:17 字数 155 浏览 0 评论 0 原文

我需要将不同 MySQL 数据库从多个服务器复制到单个从服务器中。这怎么能做到呢?我是否需要在从属服务器上为每个主服务器提供单独的 MySQL 实例?或者有没有办法定义多个master主机?

我们基本上使用从站作为多个网站的热备份。我们应该考虑集群而不是复制吗?

I need to replicate different MySQL databases from multiple servers into a single slave server. How can this be done? Do I need a separate MySQL instance on the slave for each master server? Or is there a way to define multiple master hosts?

We're basically using the slave as a hot backup for multiple websites. Should we be thinking about clustering instead of replication?

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

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

发布评论

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

评论(3

森林迷了鹿 2024-12-13 12:07:17

实现这一目标的最佳方法是一个真正的备份解决方案......但是当您按照您描述的方式为每个主设备定义一个从属实例时,您可以保持灵活性,例如,如果需要任何更改,您甚至可以移动一个或多个将从属实例转移到另一台机器,而不会对其他从属/主控产生任何影响...

编辑 - 根据评论:

有关如何在同一台机器上设置多个 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)...

攒眉千度 2024-12-13 12:07:17

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/

我ぃ本無心為│何有愛 2024-12-13 12:07:17

您将必须使用 mysql 的多个实例。如果你有6个master并且你试图将所有slave放在一台物理机器上,你将需要6个实例,

  • 每个mysql Slave实例将连接到不同的master。
  • 每个从属实例将位于不同的端口上
  • 每个从属实例的数据目录也将是独立的。

假设您使用某种风格的 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,

  • Each mysql slave instance will connect to a different master.
  • Each slave instance will be on a different port
  • The datadir for each slave instance will also be separate.

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.

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