Reduce human interaction when using an asynchronous slave to a MySQL InnoDB Cluster

on

A MySQL replication topology can be very complex (never underestimate a DBA’s creativity). But it’s very frequent to use an asynchronous slave from your primary database to run reporting or logical backup… or any kind of read workload you need. It can also be used as delay slave for data restore purpose.

Once you decided to provide HA to your primary database by migrating to MySQL InnoDB Cluster, you can of course still need and use one or more asynchronous slaves.

You have then an architecture that looks like this :

So as you can notice, your asynchronous slave needs to pick one of the members of the cluster as master. However when this node that act as master crashes (or is stopped for maintenance) what’s happening ?

In fact, replication will break and a human intervention (or a script) will have to change the master on the slave and restart replication to keep the changes again:

As InnoDB Cluster is using GTIDs, this operation is easy, but it would be even better if this change could be done automatically more quickly and without human intervention.

Thanks to the router this is possible ! The plan is to run MySQL Router on the slave itself and connect the replication locally.

This is how it looks like :

 

The process is then fully automated and no human intervention is required. So the router is very useful to connect applications to the cluster but not only. Of course multiple slaves can use the same router or have their own router to replicate from the InnoDB Cluster.

14 thoughts on “Reduce human interaction when using an asynchronous slave to a MySQL InnoDB Cluster

  1. Hi,
    Thanks for the nice pictorial information.
    The concept of asynchronous slave to a cluster via local router is working good only when the node was down.
    if the node is removed from the cluster, the asynchronous node is still pointing to the removed node and the changes that are made in the removed node is being replicated to the asynchronous node.
    can you suggest if there is anyway to get this issue resolved ?

  2. Hi lefred ,

    Have you tried two InnoDB Cluster with Master – Master Classic Replication in between using MySQL Router?

    Note: Let us assume the Application Layer will handle conflict resolution

  3. hello sir
    my question is what if the whole cluster goes down? is the slave node connected to the cluster become the master?if not, my scenario i want to reach is switching to a remote master node in case the cluster went down
    than you in advance

    1. Hi Ragheed,
      In this scenario, it does not. But it’s possible, you will have to configure the primary node to be asynchronous slave of the new promoted Asynchronous Master (previous slave). As soon as one Group Member (cluster node) becomes an asynchronous slave, the full cluster becomes a slave.
      Regards,

  4. Hi lefred
    thank you for you reply.
    so if i got it right, once i configure the Master node in the cluster as async slave, the whole cluster become slave to the remote Master.
    my scenario is to do a primary(cluster) and DR (single node) sites. so whenever the primary site goes down the DR node becomes the master until the Primary site get fixed.
    right??
    thank you in advance

    1. Hi Ragheed,

      You need to take care of the routing by yourself currently, the MySQL Router won’t take that slave in consideration.
      Also once the async slave is promoted as async master, you need to take care that nobody will write on the cluster if it shows up. When cluster is back, you need to configure the Primary node to be slave of the async-master and only when it catch up you can switch back roles.

      Cheers,

  5. Hello,
    I have implemented similar kinda setup in our environment
    DataCenter1_node1 gets aysnc replication events from MySQL router that is installed on node1 itself
    MySQL router has the view of DataCenter2 cluster and vice versa for DataCenter2_node1

    what if complete DC1_node1 is powered off unknowingly.

    will the async repl switch automatically to another node; say node2
    do we have to write a script to switch the async repl node to the new primary instance.

    I understand Group Replication will take care of electing new primary host but what about aysnc replication failover

    Any thoughts on this?

    Regards
    Sudi

    1. Hi Sudi,
      In this example, there is only one DC. It seems you are talking about 2 DCs.
      Are you using 2 different groups ?
      Currently if the Asynchronous Master (which is the Primary Master) dies, then the router will send the replica to the new Master. If the replica dies… nothing happens and you have to promote a new replica by yourself.
      Cheers.

      1. Hi Lefred,
        Thank you for your reply.
        Yes in my case,
        There are 2 DataCenters (DC); so 2 separate MySQL8 Group Replication cluster exists. Active site and DR site.
        Bi-Directional Async replication is setup between primary Host for each of the DC;

        DC1_node1—> Async repl —-> node1_mysqlrouter. —->DC2_node1
        DC2_node1 –> Async repl –> DC2_node1_mysqlrouter –> DC1_node1
        Note: mysql8 & mysqlrouter are installed on same host

        if DC1_node1 or DC2_node1 goes completely down Async replication is broken.
        So is manual commands/script only the option to point Async replication to newly elected primary host?

        Regards
        Sudi

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

recent
categories