In this post, I will show how we can create a mariadb galera cluster of three nodes in Cent OS 6.x. This will bring you an idea of the setup and configurations and At the end I am sure you will be able to implement the same in other CentOS or RHEL distributions.
Overview of Galera Cluster MariaDB :
Galera cluster is a multi-master database setup which replicates the data synchronously among the nodes. Generally, we use MySQL or MariaDB server to create a Galera Cluster which uses Galera Replication plugin to replicate the data. It is always recommended to keep the “quorum mechanism” while setting up the galera cluster nodes. For more information on the “Quorum Mechanism”, have a look in the Galera Cluster Weighted Quorum Documentation.
Galera Cluster Setup in CentOS 6 :
The first step is to setup the MariaDB server in all the nodes of the cluster. Here’s how to install MariaDB server in centOS 6.x.
Setup Yum Repo at /etc/yum.repos.d/MariaDB.repo
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
To install MariaDB using Yum, run the commands below :
yum clean all yum install MariaDB-Galera-server MariaDB-client galera service mysql start mysql_secure_installation
Run the command to check whether the MariaDB server is running successfully or not.
mysql -uroot -p<YOUR PASSWORD (IF ANY)>
Once you succeed in installing MariaDB, stop the service for now by using the command –
service mysql stop
Galera Cluster Configuration :
Go to /etc/my.cnf and check for the following configurations. Here I am considering that you are going to involve three nodes in the galera cluster… and the IP addresses are 184.108.40.206, 220.127.116.11, 18.104.22.168.
I am providing a snapshot of the specific properties in my /etc/my.cnf configured for Galera Cluster –
.... [mariadb] query_cache_size=0 binlog_format=ROW default_storage_engine=innodb innodb_autoinc_lock_mode=2 wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address=gcomm://22.214.171.124,126.96.36.199,188.8.131.52 wsrep_cluster_name='cluster1' wsrep_node_address='184.108.40.206' wsrep_node_name='db1' wsrep_sst_method=rsync wsrep_sst_auth=<USER_NAME>:<PASSWORD> ....
Here the “wsrep_sst_auth” is the username:password of my MariaDB server. Make sure you put proper values at username:password against “wsrep_sst_auth” property.
The same /etc/my.cnf should be pasted in each of the nodes, just we have to change the values of “wsrep_cluster_name” and “wsrep_node_address”.
Get It Started :
The very first node, that is the “db1” should be started with below command –
The other nodes should be started with the normal command like –
While starting the other nodes, if you find the message like ‘Starting MySQL….SST in progress, setting sleep higher. SUCCESS! ‘, you are DONE !!! 👍
Check the Cluster Status :
Go to the “db1” and run –
$> mysql -uroot -p<YOUR PASSWORD> MariaDB [(none)]> show status like 'wsrep%';
You will get to see the nodes’ IP and the port currently in the cluster.
wsrep_incoming_addresses | 220.127.116.11:3306,18.104.22.168:3306,22.214.171.124:3306
After reading this article I am sure you will be able to setup a Galera Cluster by your own. If you have any question, please feel free to ask me in the Comment section. Request you to Like and Share this article, if you have found it useful.