MariaDB Galera three nodes cluster on CentOS 6

mariadb-galera-cluster-centos-6

Let’s build MariaDB Galera cluster with three nodes on CentOS x64 6.7 Minimal.
On all nodes static IP adresses have been configured.
Node1- 10.20.20.11
Node2 – 10.20.20.12
Node3 – 10.20.20.13

On all nodes we need to install necessary packages:

On all nodes it’s necessary to configure and syncronize clock. In other case there might be a situation when a node that is being syncronized is just waiting something without any further actions.

Let’s start ntpd service an add it to autostart:

Disable Selinux:

Now open ports 4567,4568 (Galera), 3308 (MariaDB), 4444 (rsync_sst) in iptables:

An example of iptables configuration:

Install Percona and MariaDB repositories:

Insert into a file:

Now we can install MariaDB and Percona packages:

On all three nodes execute commands:

Save a backup copy of configuration file and fill in the new file:

Copy the file to other two nodes and make sure that for all three nodes the next options have been set correctly:
wsrep_cluster_name = the name of cluster. It’s the same for all nodes.
wsrep_cluster_address = string with IP adresses of all nodes in the cluster gcomm://IP1,IP2,..,IPn. It’s the same for all nodes.
wsrep_node_address = IP address of the node with this configuration file. If there is only one network adapter we can leave this option commented.
wsrep_node_incoming_address = IP address of the node with this configuration file. If there is only one network adapter we can leave this option commented.

Now we are ready to start the cluster!
Let’s initialize cluster on the first node:

…and start other two:

Now let’s check cluster’s status and make sure that all nodes are online. Execute (on any node):

All three nodes are online.

In order to check other cluster-related info execute:

In order to make sure that replication is working let’s create some test database:

We should immediately see it on other nodes:

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com