MariaDB Galera Cluster is a synchronous multi-master cluster for MariaDB. It is available on Linux only, and only supports the XtraDB/InnoDB storage engines (although there is experimental support for MyISAM - see the wsrep_replicate_myisam system variable).
Starting with MariaDB 10.1, the wsrep API for Galera Cluster is included by default. This is available as a separate download for MariaDB 10.0 and MariaDB 5.5.
MariaDB has one of the best and easiest solutions to do a Master-Master replication: Galera. Galera uses WSREP, which it is responsible for maintaining all the Database nodes in the cluster in sync. This means, after changing one record on node A, it is just a matter of seconds to see the change on node B.
I will talk in this article how I did this configuration using MariaDB 10.1.x. Remember you can install MariaDB under Centos 6 and 7 by using OKay's repository.
The first thing you must install the galera plugin. You can do that by typing yum install galera. This will install the file /usr/lib64/galera/libgalera_smm.so which is very important.
After that, what I did is to create a file /etc/my.cnf.d/galera.cnf with the following content.
# Galera Provider Configuration
# Galera Cluster Configuration
# Galera Synchronization Congifuration
# Galera Node Configuration
You should substitute the IP addresses and the node names. The wsre_provider_options are to add security; because I do recommend to use public IP's instead of any VPN when doing synchronization, you should have some kind of confidentiality control. To archive this, we use certificates. Take note that certificates must be in PEM format.
Copy this sample on all your nodes.
To start the node, the first node must be started with an option. In this case, first MariaDB node must be started like this: service mysql start --wsrep-new-cluster (for Centos 6). Wait one minute, and then you can start others as usual. For Centos 7, you can not do that, you should do something like: systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' && systemctl start mariadb