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: 172.16.8.5, 172.16.8.6, and 172.16.8.4. 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

Ubuntu Precise

Yes, they are nearly identical. :)

Install Packages

(Just another shortcut for the impatient)

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: 172.16.8.5, 172.16.8.6, 172.16.8.4) 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:

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.

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).

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

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.

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.

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

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.

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:

Great.

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 teuto.net for providing me an OpenStack tenant, so I could run the tests for this Howto.

MariaDB is participating in the Google Summer of Code 2014. Students are encouraged to propose a project before the deadline (this Friday!).

This is our second year participating, and as always we have an ideas page available. We also have a list of things we think are achievable in JIRA – check out our gsoc14 tag.

In 2013, we had three projects, of which two are in MariaDB 10.0: PCRE regular expressions and Roles. The other will be targeted towards MariaDB 10.1. There’s nothing like having GSoC students participate and have their code in shipping products.

So if you’re interested in all things MariaDB/MySQL, want to make a meaningful contribution to an opensource database, don’t hesitate to apply as a student!

The MariaDB project is pleased to announce the immediate availability of MariaDB 10.0.9. This is a Release Candidate release.

Among other changes, XtraDB is now the default InnoDB implementation, Oracle’s InnoDB is included as a plugin and can be dynamically loaded if desired. Packages for Ubuntu 14.04 “trusty” and Debian “Sid” have also been added to the MariaDB Ubuntu and Debian repositories.

See the Release Notes and Changelog for detailed information on this release and the What is MariaDB 10.0? page in the MariaDB Knowledge Base for general information about the MariaDB 10.0 series.

Download MariaDB 10.0.9

Release Notes Changelog What is MariaDB 10.0?

MariaDB APT and YUM Repository Configuration Generator

Thanks, and enjoy MariaDB!