Our Blog

Stuff about the modern world…

MariaDB 10.1 Galera Cluster on Debian 8 Jessie

Posted by Christoph Haas on 10 03 2016. 2 Kommentare zu MariaDB 10.1 Galera Cluster on Debian 8 Jessie

This is a Howto about installing MariaDB Galera Cluster on Debian 8 Jessie.

Installing MariaDB Galera Cluster is in fact quite easy and actually kind of boring in the end. This Howto is written for (and tested on) on Debian 8.3 (Jessie).

What we need

In our setup we assume 3 nodes (cluster01, cluster02, cluster03) with one interface each. We assume following IP addresses:,, and


We need three packages installed on all nodes:

  • rsync
  • galera-3
  • mariadb-server

As Galera does not ship with the distribution repositories, go for the repo configurator and follow the instructions to include the repository fitting your system. Keep in mind to Choose „10.1“ in Step 3 (Choose a Version).

Install Packages

(Just another shortcut for the impatient)

apt-get install -y rsync galera-3 mariadb-server

After installing the packages you will have a running MariaDB server on each node. But none of them will be configured to run as a node in a MariaDB Galera Cluster.

Configuring Galera

So we have to do some configuration next. There is a MariaDB configuration part and one part to configure Galera (starting with wsrep_). As we do the most basic and simple installation in this Howto, it is sufficient you just change the IP’s (Remember:,, with your IP’s. In our example, we have set hostnames on each node (cluster01, cluster02, cluster03) so we do not need the IP addresses of the hosts.
This will be needed to define the wsrep_cluster_address Variable (the list of nodes a starting mysqld contacts to join the cluster).

The following configuration file has to be distributed on all nodes. We use a separate configuration file (create a new file) /etc/mysql/conf.d/galera.cnf with the following settings:

#mysql settings

#galera settings

FYI: The shared library for wsrep_provider is provided by the installed galera package.

We could also change the cluster name by changing the value of wserp_cluster_name to fit our style. This setting also works as a shared secret to control the access to the cluster.

With wsrep_cluster_address you see the hostnames of our setup. wsrep_cluster_address could also be gcomm://,, Multiple IP’s or hostnames have to be comma seperated.

The wsrep_sst_method tells what method to use to synchronise the nodes. While there are also mysqldump and xtrabackup available, I prefer rsync because it is easy to configure (i.e. it does not need any credentials set on the nodes). If you are considering using the xtrabackup method, don’t forget to install xtrabackup.

Now stop mysqld on all nodes:

cluster01# systemctl stop mysql
cluster02# systemctl stop mysql
cluster03# systemctl stop mysql

Debian/Ubuntu uses a special user (‚debian-sys-maint’@’localhost‘) in their init script and the credentials for that user are stored in /etc/mysql/debian.cnf. This user is used to make some checks starting MySQL. Checks I don’t think belong into a service script anyway. Because of the unique password for the user on each system, mysqld will throw some errors while starting and stopping.
We could simply ignore it, but the user is also used to shutdown mysqld. This is also not required, as a SIGTERM is sufficient to shutdown the mysqld :/
So we’ve got to fix it, by copying /etc/mysql/debian.cnf from the first node (cluster01) to all other nodes. So the data and configuration files have the same data.

Starting the Galera Cluster

The configuration file (galera.cnf) is already distributed to all nodes, so we next start the first mysqld on cluster01. This node initializes/starts the cluster (creates a GTID).

cluster01# galera_new_cluster

To have a look and see if everything really worked we’ll check the cluster size status variable.

cluster01# mysql -u root -p -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'
| cluster size |
| 1            |

If you see the above, great! That’s what we would expect. Now that the Cluster already exists, we let the next nodes just start and join the cluster.

cluster02# systemctl start mysql

Let’s pause here and do a quick check. As we are running a cluster it is not important if we execute the following on cluster01 or cluster02.

mysql -u root -p -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'
| cluster size |
| 2            |

If you see the above, very nice! Now let’s start the third node:

cluster03# systemctl start mysql

Ok we are finished. We have a running MariaDB Galera Cluster \o/

Restarting the whole Galera Cluster

If the whole galera cluster has to be restarted (due to poweroutage for example) we have to complete the following steps by hand:

  1. Identify the node with the most advanced node state ID.
  2. Start the most advanced node as the first node of the cluster.
  3. Start the rest of the node as usual.

Identify the node with the most advanced node state ID.

cat /var/lib/mysql/grastate.dat

The node with the highest seqno is your new first host.

Start the most advanced node as the first node of the cluster.

On the new first host, the one with the highes squence number, bootstrap the galera cluster again:


Start the rest of the node as usual.

On each other node start mysqld as usual:

 systemctl start mysql



This tutorial is based on https://mariadb.org/installing-mariadb-galera-cluster-on-debian-ubuntu/ by Erkan Yanar

Comments ( 2 )

Schreibe einen Kommentar

  • fachamix

    GENIOOO , tremendo tutorial. muchas gracias desde Argentina August 18, 2016 at 5:23 am

  • Raymond Brennan

    Excellent tutorial. Saved me days of Googling. The only thing I would add is the need for an extra line at the end of galera.cnf with wsrep-node-address= IP address of the local server. I found that without this, restarting the whole cluster failed because the database was marked as corrupt and wouldn't start. Oktober 21, 2016 at 12:09 pm