mysql故障转移:如何选择slave作为新master? [英] mysql failover: how to choose slave as new master?

查看:240
本文介绍了mysql故障转移:如何选择slave作为新master?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是mysql新手.

在进行故障转移时,应将哪个从站提升为新的主站?

when it comes to fail-over, which slave should be promoted to the new master?

例如,A是主服务器,B和C是从服务器,而A会异步复制到B和C.

For example, A is master, B and C are slaves, and A does async replication to B and C.

在某个时间点,B从A接收的数据比C接收的数据多,A崩溃了.

At some point of time, B receives more data from A than C, A crashes.

如果我们将C提升为新的母版,并将B的母版更改为C,那么B会怎样?它会截断数据以匹配C?

If we promote C to new master, and changes B's master to C, then what happens to B? It truncates its data to match C?

很明显,B是最好的新硕士候选人,但我的问题是,如何确定这一事实?

Obviously, B is the best new master candidate, but my question is, how to determine this fact?

推荐答案

来自

From the MySQL documentation, there two ways to set up a master-slave architecture. The traditional way, using the log files to replicate transactions and the new version (5.6+) using GTIDs (global transaction identifiers).

如果选择使用GTID进行故障转移处理,则将使用

If you choose to use GTIDs to make the failover handling you will use the mysqlfailover utility. The utility handles fails of master in one of three ways defined by the database administrator:

  • auto(默认):在首选从站列表中搜索成为主站,如果没有可用的主机,则选择另一个从站.所选的从站首先成为所有其他从站的从站,并将所有其他从站的更改复制到该从站,这样,新的主站将成为最新版本.
  • elect:与上述相同,除了如果列表中没有可用的从属服务器,它将返回错误并完成(无故障转移)
  • 失败:没有发生故障转移mysqlfailover只会监视数据库并在发生失败时返回错误.

传统方式要求您实现数据库管理的脚本,并且可以更好地解释此处.

The traditional way requires that you implement your own script to database management and is better explained here.

这篇关于mysql故障转移:如何选择slave作为新master?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆