Overview

Innodb CLuster is a modern solution to provide group replication for MySQL. In this configuration, one node is primary (RW) while the rest are ONLINE (RO)

Of course our IPs will look different because I am waaaay too lazy to care for proper pictures.

Installation

I am not big fan of manual work, ask my grandma about it. So I automated the whole shabang using Terraform + Ansible. Now, I will not show the terraform because it is strictly specific, but I will show you the ansible

Preparation

Configuration

After that you can configure the rest using the following ansible:

Configuration

Congrats, now we have the cluster running:

Cluster status

Templates

Because we want to look (only to look like, being one is boring) professional, here are the template files:

Templates

Management

It is all cool and stuff, but let's go through several scenarios with our cluster:

1. Loss of a member 2. Backup 3. Recovery

First thing first, what we do if the connection between the primary and the secondary fails, well we have to rejoin, let's see how.

Loss of a member

To do that, we will simulate a stop of the service, someone stopped our service .

Loss of a node

Since our cluster can tolerate one failure, after that, it cannot tolerate anymore:

Cluster check

We see that the node is down. So let's try to simulate a restoration of the connection:

Start the service

Now we can check again:

Check again

Now we see that it is working, if for some reason it doesn't connect, we can try to force it using the:

Rejoin and rescan

It is important that if the UUID was changed, we have to remove the instance from the metadata before adding it:

In case UUID is changed

Backup

Restore