MySQL MHA 典型使用场景

1      管理节点部署位置

1.1.       Dedicated Manager server and multiple MySQL (master,slaves) servers

使用专用的管理服务器管理多组MySQL主从服务器

Since MHA Manager uses very little CPU/Memory resources, you can manage lots of (master, slaves) pairs from single MHA Manager. It is even possible to manage 100+ pairs from single manager server.

1.2.       Running MHA Manager on one of MySQL slaves

在一个从库上部署管理节点

If you have only one (master, slaves) pair, you may not like allocating dedicated hardware for MHA Manager because it adds relatively high costs. In such cases, running MHA Manager on one of slaves makes sense. Note that current version of MHA Manager connects to MySQL slave server via SSH even though the MySQL server is located on the same host as MHA Manager, so you need to enable SSH public key authentication from the same host.

2      不同主从配置下的主从切换场景

2.1         Single master, multiple slaves(单主多从)

        M(RW)                            M(RW), promoted from S1
         |                                             |
  +------+------+        --(master crash)-->     +-----+-----+
 S1(R) S2(R)   S3(R)                           S2(R)        S3(R)

This is the most common replication settings. MHA works very well here.

2.2         Single master, multiple slaves (one on remote datacenter) 单主多从,一个从位于远程数据中心

        M(RW)                                M(RW), promoted from S1
         |                                                 |
  +------+---------+         --(master crash)-->     +-----+------+
 S1(R) S2(R)     Sr(R,no_master=1)                   S2(R)         Sr(R,no_master=1)

In many cases you want to deploy at least one slave server on a remote datacenter. When the master crashes, you may not want to promote the remote slave to the new master, but let one of other slaves running on the local datacenter become the new master. MHA supports such requirements. Setting no_master=1 in the configuration file makes the slave never becomes new master.

2.3         Single master, multiple slaves, one candidate master(单主多从,一个候选主)

      M(RW)-----S0(R,candidate_master=1)   M(RW), promoted from S0
       |                                          |
  +----+----+          --(master crash)-->   +----+----+
 S1(R)     S2(R)                             S1(R)      S2(R)

In some cases you may want to promote a specific server to the new master if the current master crashes. In such cases, setting candidate_master=1 in the configuration file will help.

2.4         Multiple masters, multiple slaves(多主多从)

      M(RW)<--->M2(R,candidate_master=1)   M(RW), promoted from M2
       |                                          |
  +----+----+          --(master crash)-->   +----+----+
 S(R)     S2(R)                             S1(R)      S2(R)

In some cases you may want to use multi-master configurations, and you may want to make the read-only master the new master if the current master crashes. MHA Manager supports multi-master configurations as long as all non-primary masters (M2 in this figure) are read-only.

2.5         Three tier replication(三层复制架构)

        M(RW)                                   M(RW), promoted from S1
         |                                                 |
  +------+---------+         --(master crash)-->     +-----+------+
 S1(R) S2(R)     Sr(R)                              S2(R)       Sr(R)
                   |                                              |
                   +                                              +
                  Sr2                                            Sr2

In some cases you may want to use three-tier replication like this. MHA can still be used for master failover. In the configuration file, manage the master and all second-tier slaves (in this figure, add M,S1,S2 and Sr in the MHA config file, but do not add Sr2). If the current master (M) fails, MHA automatically promotes one of the second-tier slaves(S1,S2,Sr, and you can also set priorities) to the new master, and recover the rest second-tier slaves. The third tier slave(Sr2) is not managed by MHA, but as long as Sr (Sr2's master) is alive, Sr2 can continue replication without changing anything.

If Sr crashes, Sr2 can't continue replication because Sr2's master is Sr. MHA can NOT be used to recover Sr2. This is where support for global transaction id is desired. Hopefully this is less serious than master crash.

2.6         Three tier replication, multi-master(三层复制架构,多主)

   M1(host1,RW) <-----------------> M2(host2,read-only)
        |                                |
  +-----+--------+                       +
 S1(host3,R)    S2(host4,R)             S3(host5,R)

=> After failover

          M2(host2,RW)

                 |

  +--------------+--------------------------+

 S1(host3,R)    S2(host4,R)             S3(host5,R)

This structure is also supported. In this case, host5 is a third-tier slave, so MHA does not manage host5(MHA does not execute CHANGE MASTER on host5 when the primary master host1 fails). When current master host1 is down, host2 will be new master, so host5 can keep replication from host2 without doing anything. Here are configuration file example.

[server default]
multi_tier_slave=1

[server1]
hostname=host1
candidate_master=1

[server2]
hostname=host2
candidate_master=1

[server3]
hostname=host3

[server4]
hostname=host4

[server5]
hostname=host5

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏java闲聊

Netty入门(一)

在文章开始之前首先明确一个问题,为什么要使用Netty,Netty解决了什么问题,围绕着这个问题我们开始本篇文章的学习

1432
来自专栏杨建荣的学习笔记

dg broker校验失败的一个奇怪问题(二) (r8笔记第51天)

对昨天提出的问题做了一个简单的分析和排查,也算是有了一个交代,上一篇文章在 dg broker校验失败的一个奇怪问题 我查看了最近的日志,发现在半个月以前有一...

3525
来自专栏乐沙弥的世界

ORA-27102: out of memory 故障

      最近的UAT数据库迁移,由于是多个DB需要迁移到同一台机器,一部分完成后,启动后续数据库碰到了ORA-27102错误,提示内存超出,查看系统可用内存...

832
来自专栏Kubernetes

Kubernetes Nginx Ingress Controller源码分析

main controllers/nginx/pkg/cmd/controller/main.go:29 func main() { // start a ...

53410
来自专栏安恒网络空间安全讲武堂

HackTheBox - Poison Writeup

来源:https://www.absolomb.com/2018-09-08-HackTheBox-Poison/

1282
来自专栏IT杂记

Linux主机之间ssh免密登录配置

修改ssh配置 每台linux主机修改配置文件/etc/ssh/sshd_config RSAAuthentication yes PubkeyAuthenti...

29610
来自专栏Kubernetes

SkyDNS2源码分析

SkyDNS2是SkyDNS Version 2.x的统称,其官方文档只有README.md,网上能找到的资料也不多,因此需要我们自行对代码进行一定的分析,才能...

4036
来自专栏Kubernetes

Kubernetes Nginx Ingress Controller源码分析之创建篇

main controllers/nginx/pkg/cmd/controller/main.go:29 func main() { // start a ...

8077
来自专栏Ryan Miao

spring in action 4th --- quick start

读spring in action.  环境搭建 quick-start依赖注入 面向切面 1.环境搭建 jdk1.8 gradle 2.12 Intelij...

2958
来自专栏我的技术专栏

Socket编程实践(3) 多连接服务器实现与简单P2P聊天程序例程

1533

扫码关注云+社区

领取腾讯云代金券