Running MariaDB Galera Cluster On CentOS

mariadb-galeraIn this quick tutorial I will list out some necessary steps to setting up mariadb galera cluster on CentOS. The selected CentOS version is 6.5 and the MariaDB is running with the 10.0 version.


We will need to install required softwares as regular:

  1. Disable SELinux:

    [bash]setenforce 0[/bash]

  2. Add MariaDB repo to /etc/yum.repos.d/mariadb.repo using MariaDB Repository Configuration tool. For CentOS 6 64-bit:

    [bash]# MariaDB 10.0 CentOS repository list – created 2015-03-16 12:01 UTC
    name = MariaDB
    baseurl =

  3. Add Epel repository:

    [bash]rpm -ivh[/bash]

  4. Install socat:

    [bash]yum install socat[/bash]

  5. Install MariaDB Glera:

    [bash]yum install MariaDB-Galera-server MariaDB-client galera which rsync[/bash]

  6. Start MySQL and Secure MariaDB after installation:


Setting up MariaDB Galera Cluster

There is an assumption that the IP and node name of the cluster’s nodes are as follows

  • Cluster node 1: hostname c1 and IP address
  • Cluster node 2: hostname c2 and IP address
  • Cluster node 3: hostname c3 and IP address
  1. Create a new MariaDB Galera Cluster user. In this case, we can choose to create a new user which is allowed to connect from any host (%) or just some pre-defined host. Of course the later option is more secure. However to be simple, I use % as the host so that the user can be connected from anywhere. The IP restriction will be done via network firewall, not inside the MariaDB configuration. Steps:

    [bash][root@c1 ~]# mysql -u root -p

    MariaDB [(none)]> GRANT USAGE ON *.* to sst_user@’%’ IDENTIFIED BY ‘STT_PASSWORD’;
    MariaDB [(none)]> GRANT ALL PRIVILEGES on *.* to sst_user@’%’;
    MariaDB [(none)]> FLUSH PRIVILEGES;
    MariaDB [(none)]> quit;

  2. Stop MariaDB in ALL nodes:

    [bash]service mysql stop[/bash]

  3. Create MariaDB cluster config, just need to edit /etc/my.cnf.d/server.cnf and add the following configuration under [mariadb-10.0]:


  4. Apply the configure in the master node for all 2nd and 3rd nodes. Remember that we need to change wsrep_node_address and wsrep_node_name to match information on these nodes.
  5. Start the first node:

    [bash]/etc/init.d/mysql start –wsrep-new-cluster[/bash]

    Remember that in case you restart the mysql server in this first node, if other nodes are currently up and running, do not use –wsrep-new-cluster again or it will create a new cluster and other running nodes cannot connect to this (until you restart all other nodes). This parameter is only be used when the node to start is the FIRST / ONLY node in the cluster.

  6. Start 2nd and 3rd nodes:

    [bash]service mysql start[/bash]

  7. Test the cluster configuration on each node:

    [bash]mysql -uroot -p -e "show status like ‘wsrep%’"[/bash]

  8. Well, we can then verify the cluster by adding database, data to any node and test the data in the remaining nodes.


  1. Always remember to have rsync and which installed in each of your node. I did have a problem of starting slave nodes just because of the lack of which so it generated the error relates to wsrep_sst_rsync.
  2. In Debian/Ubuntu, we might face stupid error due to the incompatible dependencies. E.g.

    [bash]root@euonline:~# apt-get install -y rsync galera mariadb-galera-server

    The following packages have unmet dependencies:
    mariadb-galera-server : Depends: mariadb-galera-server-10.0 (= 10.0.17+maria-1~wheezy) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.[/bash]

    . In this case, just install the exact version of mariadb galera such as

    [bash]apt-get install -y rsync mariadb-galera-server-10.0[/bash]

  3. Ports to be opened in both IN and OUT traffic: 3306,4444,4567,4568
  4. Be careful when playing with auto-increment value since this kind of value will not increased by 1, but by the number of node. This feature helps concurrent writes on any node so just aware of it :-). Reference:
  5. If you are on CentOS 7 and selinux is on, remember to turn selinux to permissive for mysqld
    [bash]semanage permissive -a mysqld_t[/bash]
    . Otherwise, you will not be able to start galera cluster since other node cannot connect to mysqld service in this server.
  6. If you use MariaDB from 10.1, MariaDB-Galera-server is not available. The galera is included in the MariaDB-server itself, so you just need to install MariaDB-server package.

About NhocConan

A super lazy guy who tries to write tech blog entries in English.He is lazy, so he can only write when he is in a good mood or when he is tired of coding.

Leave a comment

Your email address will not be published. Required fields are marked *