MySQL cluster Replication and Failover via docker-compose

Posted on

Question :

I am using docker-compose to create MySQL cluster (NDB). After cluster gets created. This is my cluster configuration:

ndb_mgm> show
Connected to Management Server at: mysql-manager-1:1186
Cluster Configuration
[ndbd(NDB)]     2 node(s)
id=11   @172.xx.0.5  (mysql-5.7.25 ndb-7.6.9, Nodegroup: 0, *)
id=12   @172.xx.0.8  (mysql-5.7.25 ndb-7.6.9, Nodegroup: 0)

[ndb_mgmd(MGM)] 2 node(s)
id=1    @172.xx.0.2  (mysql-5.7.25 ndb-7.6.9)
id=2    @172.xx.0.3  (mysql-5.7.25 ndb-7.6.9)

[mysqld(API)]   2 node(s)
id=21   @172.xx.0.4  (mysql-5.7.25 ndb-7.6.9)
id=22   @172.xx.0.7  (mysql-5.7.25 ndb-7.6.9)

When I bring down one of the SQL nodes, the cluster becomes unreachable.

E.g when node with id=21 is shut down, data should still be accessible from node id=22 because all other data nodes and management nodes are up and running.

Is this behavior supported out of the box or I have to make some configuration change for it?

I have gone through the MySQL documentation.

Am I referring to the correct documentation?

They advise executing the steps on the host machine but in my case each node is deployed as a separate docker container. How do I achieve this failover in my case?

Answer :

You may have set up replication, but failover doesn’t just magically happen by itself. You need also

  1. Some kind of cluster manager to notice the failure and initiate the failover procedure.
  2. Complete the failover procedure and ensure that the new master is operational. Part of the process is described here.
  3. A floating IP address or some sort of connection proxy to direct incoming connections to the new master.

Leave a Reply

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