MariaDB Galera Cluster

= Introduction = This is a guide for configuring a 3 node MariaDB Galera Cluster.

A MariaDB Galera cluster requires a minimal of 3 nodes. However, one of the members of the cluster can be an arbitrator (2 node + 1 arbitrator). Despite not participating in data replication, the arbitrator still needs to be on a 3rd physical node.

= Design = The Maria Galera Cluster is multi master cluster featuring synchronous writes across all nodes. Each node requires a static IP address to function.

If you have a local dns server, you can make use of that. else make use of your hosts file. This will make your system clear about the other nodes and ip address.

= Packages =

Add the galera useflag to MariaDB:

Add the garbd useflag (only) on the arbitrator. If you have 3 nodes you can skip this useflag.

Then, emerge the following packages:

= Database Initialization = Run this command and keyin your mariadb root password

= Setup Mariadb and Galera =

Start mariadb on the first node
When a node starts, by default it assumes that the cluster is already initialised and tries to join it. If no node is initialised, the cluster will not be able to start since all nodes will just try to join a (non) existing cluster. Therefore, the first node in the cluster to be online needs to be instructed to become a "new" cluster (read into STARTING THE FIRST CLUSTER NODE for more defaults):

Checking if all nodes have joined and are running correctly
Try to run this command on node 1:

If the cluster size is equal to you node size you are good to go. And wsrep_ready meant the cluster is ON.

Garbd Arbitrator Configuration
= Finalize configuration = The Mariadb cluster should now be up.

Start mariadb on boot
For openrc, do:

= Secure mariadb = Secure your mariadb for production use

= External Reference =