Typical use cases of MySQL MHA and typical use cases of mysqlmha

Source: Internet
Author: User

Typical use cases of MySQL MHA and typical use cases of mysqlmha
1 Management node deployment location 1.1. Dedicated Manager server and multiple MySQL (master, slaves) servers

Use a dedicated management server to manage multiple groups of MySQL Master/Slave servers

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

Deploy a management node on a slave Database

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 master-slave switchover scenarios with different master-slave configurations: 2.1 Single master and multiple slaves (Single master and 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) Single master multiple slaves, one slave is located in the remote data center
        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 your 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 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 (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 (Multi-master, multi-slave)
      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 be want to use multi-master deployments, and you may be want to make the read-only master the new master if the current master crashes. MHA Manager supports multi-master deployments as long as all non-primary masters (M2 in this figure) are read-only.

2.5 Three tier replication (L3 replication Architecture)
        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 (Three-layer replication architecture, 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=host1candidate_master=1[server2]hostname=host2candidate_master=1[server3]hostname=host3[server4]hostname=host4[server5]hostname=host5

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.