This blog post will cover the basic setup of the InnoDB ClusterSet environment, which provides disaster tolerance for InnoDB Cluster deployments by associating a primary InnoDB Cluster with one or more replicas in alternate locations/different data centers. InnoDB ClusterSet automatically manages replication from the primary cluster to the replica clusters via a specific ClusterSet Async replication channel. If the primary cluster becomes inaccessible due to a loss of network connectivity or a data center issue, you can make a replica cluster active in its place.

Now, let’s see in detail how exactly we can configure the topology.

InnoDB ClusterSet Deployment

We have used the sandbox environment available via MySQLShell utility for this setup.

Environment

Let’s set up the first cluster (“cluster1”)

  •  Deploying the sandboxes.

  •  Then, we need to perform some pre-checks before initiating the cluster.

Once all the instances are prepared, we can plan to create the cluster with the seed node. The “createcluster” command will perform all the hidden steps of initializing group replication, and later on, the other nodes join the group with distributed recovery/clone plugin.

InnoDB cluster is built on top of group replication which provides (automatic membership management, fault tolerance, and automatic failover). It provides us with an easy interface to deploy/manage the complex topologies with DR support.

  • We will bootstrap the cluster with an initial node(“localhost:3308″).

Output:

  • Here, we have successfully bootstrapped the first node. Next, the other nodes will join the cluster using the CLONE Plugin.

Output:

 

Output:

  • At this stage, our first cluster is ready with all three nodes.

Output:

Let’s now proceed with the second cluster (“cluster2”) setup

  • Deploying the sandboxes via MySqlShell.

  •  Similarly, perform some pre-checks as we did for “cluster1” nodes.

  •  Next, we will create the ClusterSet topology by triggering the sync on the node (127.0.0.1:3311) by existing cluster1 nodes. Node (127.0.0.1:3311) will be the Primary node for cluster2, and the rest of other nodes will join this node by Clone/Incremental process.
1) First, connect to “cluster1” node.

2) Here, “cluster1” join the ClusterSet topology,

Output:

3) Verifying the status.

Output:

 4) Now, Node (“127.0.0.1:3311″) will sync with the existing “cluster1” with Async process.

Output:

5) Next, the other nodes join the “cluster2” with the clone process.

6) Finally, checking the status of our clusterset environment.

Output:

Here, the ClusterSet topology is ready now with all six nodes.

In the next phase, we will bootstrap MySQLRouter with our newly created ClusterSet environment:

  • First, we will generate a dedicated user for MySQLRouter monitoring/management.

Output:

  • Bootstrap the router with the user (“router_usr) and router name (“Router1”).

We are using –-force here because without –-force mysqlrouter won’t recognize the clusterset. This will reconfigure the existing clusterset.

Here, we will see some useful information that later on is required to connect to a database or manage the services.

  • Finally, start the mysqlrouter service:

Validating the connection route

  •  Connect to the router port “6446” and create some demo table/data:

  •  Connect to the router port “6447” for reading purposes. Here, the connection will be, by default, balanced among the number of nodes of the Primary Cluster(cluster1).

So, by default, all the connections will route to the default “Primary” Cluster, which, in our case, is “Clustrer1”; however, we can change the primary component based on the requirement.

Changing ClusterSet topology

Output:

  • Changing the Primary cluster from “cluster1” to “cluster2:

Output:

  • If we see the output again, we can observe that  “clusterRole:PRIMARY” is shifted to “cluster2”.

Output:

So, we have changed the Primary component from cluster1 to cluster2, but the routing is still set for cluster1. In order to send traffic to cluster2, we also have to change the routing option.

Output:

  • Changing the connection target from “cluster1” to “cluster2”:

Output:

 Verifying the routing policy in the existing clusterset

Output:

There are situations when Primary clusters are not available or reachable. The immediate solution in some situations would be to perform an emergency failover in order to avoid the application block out.

An emergency failover basically switches to a selected replica cluster from the primary InnoDB Cluster for the InnoDB ClusterSet deployment. During an emergency failover process, data consistency is not assured due to async replication and other network factors, so for safety, the original primary cluster is marked as invalidated during the failover process.

So if by any chance the original primary cluster remains online, it should be shut down. Later, the invalidated primary cluster can join the clusterset via rejoin/repair process.

Perform emergency failover

Summary

With the help of ClusterSet implementation, deploying DR support over different regions is no more a complex challenge. MySQLShell and InnoDB cluster tackles all the configurations and syncing process behind the scene. The disaster recovery and failure time can be minimized with the help of the Admin APIs/MySQLShell commands.

There is one caveat with the clusterset functioning. It does not support high availability/auto-promotion of the new primary if the existing one goes down. We must take care of the same with some manual intervention or via some internal automated process.

Percona Distribution for MySQL is the most complete, stable, scalable, and secure open source MySQL solution available, delivering enterprise-grade database environments for your most critical business applications… and it’s free to use!

 

Try Percona Distribution for MySQL today!

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments