Course contentsShow
← Databases & SQL
Lesson 1029 of 1,9539. MySQL and MariaDB EcosystemsFree lesson

Galera Cluster Fundamentals

Implement synchronous multi-master replication for high-availability setups.

In this lesson, you will learn how to implement synchronous multi-master replication using Galera Cluster to achieve true high availability for your MySQL or MariaDB environments.

The Core Concept: Synchronous Replication

Unlike the asynchronous or semi-synchronous replication methods we have covered previously, Galera Cluster provides synchronous replication. In traditional asynchronous setups, there is a risk of data loss if a primary node fails before sending its binary logs to a replica. Galera eliminates this gap by ensuring that a transaction is committed on all nodes simultaneously or not at all.

When a client submits a COMMIT statement to one node, Galera performs a "Certification" process. Before the transaction is finalized, the node broadcasts the write-set to all other nodes in the cluster. If the transaction passes certification (meaning no conflicting writes occurred), it is applied across the entire cluster.

Practical Configuration

To set up a Galera node, you modify your my.cnf configuration to enable the wsrep (Write-Set Replication) provider. You must define the cluster address and the node’s local identity:

[mysqld]
# Enable the Galera provider plugin
wsrep_provider=/usr/lib/galera/libgalera_smm.so

# Define the cluster nodes
wsrep_cluster_address="gcomm://192.168.1.10,192.168.1.11,192.168.1.12"

# Local node settings
wsrep_node_address="192.168.1.10"
wsrep_sst_method=rsync

Why Multi-Master?

Because Galera treats every node as a "master," you can read and write to any node in the cluster. If one node experiences a hardware failure or network partition, the application can immediately failover to another node without waiting for manual intervention or complex orchestrators. Since all nodes contain the same data set at all times, there is zero data loss during failover.

However, keep in mind that performance is bounded by the slowest node and the network latency between them. Because the cluster must reach a consensus before committing, high network latency—which we previously analyzed in our tuning sessions—will directly impact your transaction commit speed.

Key Takeaway: Galera Cluster transforms a traditional primary-replica topology into a synchronous multi-master system, ensuring zero data loss and immediate high availability by requiring cluster-wide certification for every write operation.