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:


[galera]
wsrep_on=ON
# this varies on different versions and OSs
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=512M"
# your cluster's name
wsrep_cluster_name="cluster1"
# who belongs to the cluster
# use the next line on the first server only, the very first time only
#wsrep_cluster_address="gcomm://"
# after the first time, and on every other server, use the whole cluster
wsrep_cluster_address="gcomm://192.168.1.67,192.168.1.68,192.168.1.74"
# define method of sync (requires rsync package be installed, the default is mysqldump)
wsrep_sst_method=rsync
# 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
wsrep_sst_auth=wsrepuser:wsrep16secretpass
# put the node's unique shortname here
wsrep_node_name="mariadb1"
#wsrep_node_name="mariadb2"
#wsrep_node_name="mariadb3"
# this is where the wsrep server will bind
# put the node's storage network IP address here
wsrep_node_address="192.168.1.67"
#wsrep_node_address="192.168.1.68"
#wsrep_node_address="192.168.1.74"
# this is where mysql service will be offered
# put the node's production IP address here
bind-address="192.168.1.67"
#bind-address="192.168.1.68"
#bind-address="192.168.1.74"
query_cache_size=0
binlog_format=row
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
query_cache_type=0

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