Mariadb – Galera Cluster with MariaDB 10 and asynchronous slave

galeramariadbreplication

As it's easier to understand what I'm trying to accomplish with a picture, here's a picture:

enter image description here

I'm really not an expert in database administration, so please be patient.

I am working on a setup where I run three servers with MariaDB 10.0.12 and Galera cluster. I also have a separate installation of MariaDB that I want to run a master/slave setup where the databases gets replicated from each Galera node through keepalived and haproxy for high-availability.

After setting everything up according to a jumble of guides online, I have set up the Galera cluster and servers just fine. However, the replication to my async server doesn't seem to be working very well. Mind you I am also trying to use GTID for all of this using Using_Gtid: Slave_pos. The slave server uses the virtual IP of keepalived to connect to remotely.

Right now I'm getting the following error under the show slave status part of the slave:

Got fatal error 1236 from master when reading data from binary log: 'Could not find GTID state requested by slave in any binlog files. Probably the slave state is too old and required binlog files have been purged.'

This seems to be related to some kind of problem with the slave not being able to sync with the master servers due to the master logs being too high in value (e.g.: mariadb-bin.000080 on the master servers). Could that be the case? And if so, how do I manage to update the slave to understand that it needs to get everything up to the latest?

I really hope someone could help me out with this, or at least show me some way to better solve my current problem.

I was expecting the slave data to be synchronized from the Galera cluster at first connection and the GTID be assigned automatically, but is this is not the case? If so, how do I get the slave up to date?

Best Answer

Galera cluster auto-provisions its nodes, but that is not the case with traditional replication. You must do it manually.

Look at MariaDB documentation for setting up a slave from a backup. The process is essentially the same as doing it in MySQL, but the syntax is slightly incompatible. It usually just involves mysqldump with the --master-data and --gtid options or using Percona Xtrabackup (these methods are handled automatically among Galera nodes).

I also include a link to the MySQL documentation on setting up a new slave because even MariaDB decided to become incompatible with it, the common explanations are way better documented than on the MariaDB wiki (e.g. using mysqldump to backup a server).