MariaDB Galera Cluster is a synchronous multi-primary replication solution that allows writes to be accepted by any node in the cluster simultaneously. Unlike standard MySQL asynchronous replication, Galera ensures that a transaction is committed on all nodes before it is acknowledged to the application, eliminating replication lag and the risk of data loss during failover. A three-node Galera cluster is the minimum recommended topology because it provides quorum-based split-brain protection. This tutorial configures a three-node Galera cluster on RHEL 8 using MariaDB from the default AppStream repository.

Prerequisites

  • Three RHEL 8 servers (physical, virtual, or containers) each with at least 2 GB RAM
  • Unique static IP addresses for each node; this tutorial uses node1 (192.168.1.10), node2 (192.168.1.11), and node3 (192.168.1.12)
  • Root or sudo privileges on all three nodes
  • firewalld installed and active on all nodes
  • All three nodes able to reach each other over the network

Step 1 — Install MariaDB and the Galera Package on All Nodes

Run the following commands on all three nodes. The galera package provides the WSREP provider library that MariaDB loads to enable cluster communication.

# Run on node1, node2, and node3

dnf install -y mariadb-server galera

# Do NOT start MariaDB yet — configure Galera first
systemctl enable mariadb

Step 2 — Configure Galera on Each Node

Create a Galera-specific configuration file on each node. The key difference between nodes is the wsrep_node_address and wsrep_node_name values, which must be unique per node.

# /etc/my.cnf.d/galera.cnf — node1 version
# Repeat on node2/node3, changing wsrep_node_address and wsrep_node_name

[mysqld]
# Enable WSREP (Galera) replication
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so

# List all cluster nodes — same on all three nodes
wsrep_cluster_address="gcomm://192.168.1.10,192.168.1.11,192.168.1.12"
wsrep_cluster_name="pr_galera_cluster"

# Unique per node
wsrep_node_address="192.168.1.10"
wsrep_node_name="node1"

# Use rsync for State Snapshot Transfer (SST)
# mysqldump is an alternative but slower for large datasets
wsrep_sst_method=rsync

# InnoDB settings required for Galera
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
binlog_format=ROW

On node2, change the node-specific lines:

# On node2 only — different address and name
wsrep_node_address="192.168.1.11"
wsrep_node_name="node2"

On node3:

# On node3 only
wsrep_node_address="192.168.1.12"
wsrep_node_name="node3"

Step 3 — Open Firewall Ports on All Nodes

Galera requires several ports for cluster traffic. Open them on each node before bootstrapping.

# Run on all three nodes

# Standard MariaDB client port
firewall-cmd --permanent --add-port=3306/tcp

# Galera replication traffic
firewall-cmd --permanent --add-port=4567/tcp
firewall-cmd --permanent --add-port=4567/udp

# Incremental State Transfer (IST)
firewall-cmd --permanent --add-port=4568/tcp

# State Snapshot Transfer (SST via rsync)
firewall-cmd --permanent --add-port=4444/tcp

firewall-cmd --reload

Step 4 — Bootstrap the First Node

The first node must be bootstrapped with a special command that initializes a new cluster. This writes a fresh WSREP state UUID. Run galera_new_cluster only on node1; do not use this command when re-joining an existing cluster.

# On node1 ONLY — creates a new cluster
galera_new_cluster

# Verify node1 has formed a single-node cluster
mysql -u root -e "SHOW STATUS LIKE 'wsrep_cluster_size';"
# Expected: wsrep_cluster_size = 1

Step 5 — Start the Remaining Nodes and Verify the Cluster

Start MariaDB normally on node2 and node3. Each will contact the seed addresses in wsrep_cluster_address, receive a full SST from node1, and join the cluster automatically.

# On node2
systemctl start mariadb

# On node3
systemctl start mariadb

# Check cluster size from any node — should be 3
mysql -u root -e "SHOW STATUS LIKE 'wsrep_cluster_size';"
mysql -u root -e "SHOW STATUS LIKE 'wsrep_cluster_status';"
mysql -u root -e "SHOW STATUS LIKE 'wsrep_ready';"

# wsrep_cluster_size   = 3
# wsrep_cluster_status = Primary
# wsrep_ready          = ON

Conclusion

You now have a three-node MariaDB Galera Cluster running on RHEL 8 with synchronous multi-primary replication. Any write committed on one node is immediately available on all others, making this architecture highly suitable for applications that require zero replication lag and automatic failover. When a node fails, the remaining two nodes maintain quorum and continue serving traffic; the failed node rejoins and catches up via IST or SST automatically when it comes back online.

Next steps: How to Set Up a Load Balancer for MariaDB Galera on RHEL 8, How to Perform a Rolling Upgrade of a Galera Cluster on RHEL 8, and How to Monitor MariaDB Galera with Prometheus on RHEL 8.