Skip to content
Navigation

Type at least two characters. Search covers page titles, headings, tags and database names.

↑ ↓ to navigateEnter to openEsc to close0 pages
MariaDBadvanced

Galera Cluster

Synchronous multi-primary replication in MariaDB — how certification works, the settings it requires, and its failure modes.

3 min readAdvancedUpdated Edit this page

Galera provides synchronous, certification-based replication across MariaDB nodes. Every node holds the full dataset and can accept writes.

How certification works

At commit, the write set is broadcast to all nodes. Each node deterministically certifies it against concurrent transactions. If it conflicts, the transaction is aborted on the node that submitted it, returning a deadlock error to the client.

The consequences are specific and worth internalising:

  • Commit latency includes a cluster round trip. Galera is sensitive to network latency, which is why stretching a cluster across regions is usually a mistake.
  • Conflicts appear as deadlock errors at commit time. The application must retry them, exactly as with ordinary deadlocks.
  • Write capacity does not grow with node count. Every node applies every write. Galera buys availability, not throughput.

Required configuration

[mysqld]
wsrep_on = ON
wsrep_provider = /usr/lib/galera/libgalera_smm.so
wsrep_cluster_name = "shop-cluster"
wsrep_cluster_address = "gcomm://10.20.1.10,10.20.1.11,10.20.1.12"
wsrep_node_address = "10.20.1.10"
wsrep_node_name = "node1"
 
# Mandatory for Galera.
binlog_format = ROW
default_storage_engine = InnoDB
innodb_autoinc_lock_mode = 2
 
wsrep_sst_method = mariabackup           # non-blocking state transfer
wsrep_sst_auth = "sst_user:password"
wsrep_slave_threads = 8                  # parallel apply on receiving nodes

Constraints

Bootstrapping and quorum

A cluster needs a majority to operate. Three nodes tolerate one failure; two nodes tolerate none — losing either leaves the other without a quorum and it stops serving. Use three nodes, or two plus a lightweight arbitrator (garbd).

State transfers

A joining node needs the current state:

  • IST (incremental) — sends only the missing write sets from the donor's gcache. Fast.
  • SST (full) — a complete copy. Use mariabackup so the donor is not blocked; older methods such as rsync make the donor unavailable for the duration.

Size gcache.size so that a node restarted for a routine reason can rejoin with IST rather than a full SST. That single setting is the difference between a two-minute restart and a two-hour one on a large dataset.

Flow control

If one node applies more slowly than the cluster writes, it emits flow-control messages and the whole cluster slows to its pace.

SHOW STATUS LIKE 'wsrep_local_recv_queue_avg';   -- > 0 sustained means this node lags
SHOW STATUS LIKE 'wsrep_flow_control_paused';    -- fraction of time paused
SHOW STATUS LIKE 'wsrep_cluster_size';
SHOW STATUS LIKE 'wsrep_cluster_status';         -- should be "Primary"
SHOW STATUS LIKE 'wsrep_local_state_comment';    -- should be "Synced"

A single slow or under-provisioned node degrades everyone. Size all nodes identically.

Practical guidance