Supporting continuity and open collaboration

Installing MariaDB Galera Cluster on Debian/Ubuntu

A MariaDB Howto authored by: Erkan Yanar.

This is a Howto about installing MariaDB Galera Cluster on Debian/Ubuntu. Because a lot of people were having problems installing MariaDB Galera Cluster, elenst from #maria on freenode forced me to write this Howto 🙂

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 7.1 (Wheezy) and Ubuntu 12.04 (Precise).

What we need

In our setup we assume 3 nodes (node01, node02, node03) with one interface each. We assume following IP addresses:,, and We need three packages installed on all nodes:

  • rsync
  • galera
  • mariadb-galera-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 “5.5” in Step 3 (Choose a Version). Doing this you can jump directly to Install Packages

Adding the Repository

Alternatively you can just take following steps.

Debian Wheezy

apt-get install python-software-properties
apt-key adv --recv-keys --keyserver 0xcbcb082a1bb943db
add-apt-repository 'deb wheezy main'
apt-get update

Ubuntu Precise

apt-get install python-software-properties
apt-key adv --recv-keys --keyserver 0xcbcb082a1bb943db
add-apt-repository 'deb precise main'
apt-get update

Yes, they are nearly identical. 🙂

Install Packages

(Just another shortcut for the impatient)

DEBIAN_FRONTEND=noninteractive apt-get install -y rsync galera mariadb-galera-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.
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 /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 IP addresses of our setup. 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.

Starting the Galera Cluster

First we stop mysqld on all nodes.

node01# service mysql stop
node02# service mysql stop
node03# service mysql stop

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

node01# service mysql start --wsrep-new-cluster

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

node01# mysql -u root -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.

node2# service mysql start
[ ok ] Starting MariaDB database server: mysqld . . . . . . . . . ..
[info] Checking for corrupt, not cleanly closed and upgrade needing tables..
node01:/home/debian# ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

We can ignore the above error for now. This node is still starting fine.

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 node01 or node02.

| cluster size |
| 2            |

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

node3# service mysql start
[ ok ] Starting MariaDB database server: mysqld . . . . . . . . . ..
[info] Checking for corrupt, not cleanly closed and upgrade needing tables..
node03:/home/debian# ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

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

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

Having fun with Debian/Ubuntu init scripts

But we’ve got to fix some things because of some Debian/Ubuntu oddities.

Remember the error we saw when starting node02 and node03? What happened? Well, 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.

We could simply ignore it, but the user user is also used to shutdown mysqld. This is also not required, as a SIGTERM is sufficient to shutdown the mysqld :/

As we copied the data from node01 to all other nodes, the credentials in /etc/mysql/debian.cnf don’t match on node02 and node03. So we will not be able to shutdown mysqld on either of these nodes.

node02# service mysql stop
[FAIL] Stopping MariaDB database server: mysqld failed!

So we’ve got to fix it, by copying /etc/mysql/debian.cnf from the first node (node01) to all other nodes. So the data and configuration files have the same data again.

After that we are able to shutdown the daemon:

node02# service mysql stop
[ ok ] Stopping MariaDB database server: mysqld.


So if we would have a proper init script the Howto would have been even shorter 😉

Follow the Bug 🙂

Enjoy your MariaDB Galera Cluster and have fun!

— Erkan Yanar

Thx to for providing me an OpenStack tenant, so I could run the tests for this Howto.


  1. 2014-03-19    

    Excellent howto, thanks!

  2. MeMo MeMo

    How about on centOS/Red Hat distro?

    • Guillaume Lefranc Guillaume Lefranc

      Hi MeMo,

      if you’re interested in a CentOS HOWTO we may post that in the coming days 🙂

  3. Romain Romain

    Thx for the howto.

    I’m have two questions about client/Connector J side :
    1) are you using the standard Java Connector downloadable from or another specific connector ?

    2) Do you need to use e.g.


    as the db URL syntax ? or do you need to set up a virtual IP in front of the cluster on which the driver connects to ?


    • Guillaume Lefranc Guillaume Lefranc

      Hi Romain,

      MariaDB delivers its own LGPL connector:

      Of course, the standard Connector/J from Oracle should work also.

      The syntax you provided is correct, however it doesn’t check for node failures so it’s probably better to use SkySQL Maxscale or HAProxy for load balancing.

  4. Artex Soft Artex Soft

    It is available “yum install MariaDB-manager” for CentOs, but in Ubuntu using “apt-get” :). Are you planning to prepare installation packages MariaDB-manager to simply install “apt-get install MariaDB-Manager”?

  5. Andreas Rådén Andreas Rådén

    Under Debian Jessie, the parameter “–wsrep-new-cluster” does not seem to work. To fix this, I started the first server with “wsrep_cluster_address = gcomm://”, in other words, no IP’s provided. In this state, I started the next node and the third, which had all three IP’s configured. I then added the IP’s on the first node, and restarted the service, voila! Might be a more correct way, but this worked for me.

  6. 2016-05-21    

    I tried this mirror, but it looks to be offline. It worked fine with

    Just replaced the 3rd line with:

    add-apt-repository ‘deb wheezy main’


  7. Simone Simone

    Hi Jan,
    i’ve setup galera on 3 Debian 8 nodes, but, if i restart mysql i receive an error on binding on
    No errors on logs, how should i solve it?

    Thanks in advance

No Pings Yet

  1. Installation d'un cluster MariaDB Galera avec Ansible - Nodelia on 2016-02-01 at 16:10
  2. MariaDB 10.1 Galera Cluster on Debian 8 Jessie - Sprinternet Blog on 2016-03-10 at 14:51

Platinum Sponsors

MariaDB Foundation Platinum sponsors

Thank you,! Thank you, Alibaba Cloud! Thank you, Tencent Cloud! Thank you, Microsoft! Thank you, MariaDB Corporation!

Gold Sponsors

MariaDB Foundation Gold sponsors

Thank you, DBS! Thank you, Visma! Thank you, IBM! Thank you, Tencent Games!