MariaDB + Galera

I got a bit distracted. Just learned about MariaDB 10.1, which now includes the Galera multi-master database package built-in. I had to make it work, of course, and using three containers, it wasn’t all too hard. The documentation is a little weak at this time, because they want to sell their support contracts, but it’s not too bad.

This is what I had to add to /etc/my.cnf.d/server.conf on CentOS 7:

# this varies on different versions and OSs
# your cluster's name
# who belongs to the cluster
# use the next line on the first server only, the very first time only
# after the first time, and on every other server, use the whole cluster
# define method of sync (requires rsync package be installed, the default is mysqldump)
# you need to create this user with this passwd on node 1,
# after bring it up the first time and before joining node2
# to the cluster, for wsrep to work
# put the node's unique shortname here
# this is where the wsrep server will bind
# put the node's storage network IP address here
# this is where mysql service will be offered
# put the node's production IP address here

# Then you had to start the first node, the first time only, with:

/etc/init.d/mysql start --wsrep-new-cluster

# The you set things up:
$ mysqladmin -u root password
# enter the new root password twice

# do it again for the public interface
$ mysqladmin -u root -h mariadb1 password

$ mysql -u root -p
mysql> use mysql;
mysql> delete from user where User='';
mysql> create user wsrepuser;
mysql> grant all on *.* to 'wsrepuser'@'%' identified by 'wsrep16secretpass';

# check your wsrep process
mysql> show status like 'wsrep_cluster_size';
$ less /var/log/mysql/mysqld.log

# join node two and three (same config, uncomment that node's name and ip addresses)
# just start them like normal, then check the cluster size again and their mysqld.logs
# change the gcomm line in node 1, and restart it normally. You're up!

2 thoughts on “MariaDB + Galera

  1. whistl Post author

    Got it working at work too, on a larger, distributed cluster. Neat stuff! The docs I originally found assumed too much, but google saved the day, once again.

  2. whistl Post author

    Doing it at home first, on a modern Centos 7 cluster, made all the difference. I followed the same process at work, and just had to struggle to find the correct version of galera for that OS. Once over that hurdle, getting the cluster up was trivial.

Comments are closed.