Three nodes, synchronous replication, no single primary — a Galera cluster is the closest MariaDB gets to multi-master out of the box. This article is the install and bootstrap procedure we use when a client needs a write-anywhere MariaDB cluster for an application that cannot tolerate the failover window of async replication. We will lay down the packages on three Ubuntu nodes, configure the wsrep provider, bootstrap the first node, join the others, and verify the cluster is in the state the application expects before any traffic arrives.
How to verify
Before bootstrapping, confirm the three nodes can reach each other on the Galera ports — 3306 for client traffic, 4567 for cluster communication (TCP and UDP), 4568 for incremental state transfer, 4444 for state snapshot transfer.
ss -ltnp | grep -E ':(3306|4567|4568|4444)\b'
for host in db01 db02 db03; do nc -zv "$host" 4567; done
mysql -e "SHOW STATUS LIKE 'wsrep_cluster_size';"
mysql -e "SHOW STATUS LIKE 'wsrep_local_state_comment';"
mysql -e "SHOW STATUS LIKE 'wsrep_ready';"
wsrep_cluster_size must equal the number of nodes you expect. wsrep_local_state_comment should read Synced. wsrep_ready must be ON. Anything else means the node is not serving traffic — read the rest of SHOW STATUS LIKE 'wsrep_%' before you continue.
What’s happening
Galera is a synchronous, certification-based replication plugin that ships with MariaDB Server. Every write transaction is broadcast to all nodes, certified against concurrent transactions on every node, and only committed when every node accepts it. The result is that any node can take writes and every node sees the same data at the same logical point in time — there is no replication lag in the async sense, only the latency of the certification round trip.
The trade-off is that the slowest node sets the pace for the whole cluster, and a partitioned minority cannot accept writes. With three nodes, a single-node failure leaves a two-node majority that continues to serve traffic; a two-node failure leaves a single node that goes read-only to protect itself against split brain. This is why production Galera deployments are almost always three or five nodes — never two, never four.
State transfer between nodes happens in two flavours. SST (State Snapshot Transfer) is a full copy, used when a joining node has no data or is too far behind to catch up incrementally — mariabackup is the recommended SST method. IST (Incremental State Transfer) replays only the missing writes from the donor’s GCache, used when a node was offline briefly and the donor still has the relevant range.
The procedure
-
Install MariaDB Server and the Galera provider on all three nodes from the official MariaDB repository (the distro version is often too old for production Galera).
curl -fsSL https://mariadb.org/mariadb_release_signing_key.asc \ | sudo gpg --dearmor -o /etc/apt/keyrings/mariadb.gpg echo "deb [signed-by=/etc/apt/keyrings/mariadb.gpg] \ https://mirror.mariadb.org/repo/10.11/ubuntu jammy main" \ | sudo tee /etc/apt/sources.list.d/mariadb.list sudo apt update sudo apt install -y mariadb-server mariadb-backup galera-4 -
Stop MariaDB on every node before touching the config — Galera will refuse to start cleanly if even one node is running standalone with conflicting state.
sudo systemctl stop mariadb -
Write
/etc/mysql/mariadb.conf.d/60-galera.cnfon every node. Thewsrep_cluster_addresslists every node,wsrep_node_addressis the local IP, andwsrep_node_nameis unique per node.[galera] wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_cluster_name="prod-galera" wsrep_cluster_address="gcomm://10.0.0.11,10.0.0.12,10.0.0.13" wsrep_node_address="10.0.0.11" wsrep_node_name="db01" wsrep_sst_method=mariabackup wsrep_sst_auth="sstuser:STRONG_PASS_HERE" binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 -
Create the SST user on the first node only — it will replicate to the others during the first SST.
CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'STRONG_PASS_HERE'; GRANT RELOAD, PROCESS, LOCK TABLES, BINLOG MONITOR ON *.* TO 'sstuser'@'localhost'; FLUSH PRIVILEGES; -
Bootstrap the first node — and only the first node, only on the first start of the cluster’s life.
sudo galera_new_cluster sudo systemctl status mariadb mysql -e "SHOW STATUS LIKE 'wsrep_cluster_size';"The status query must return
1. If it returns0or errors, the bootstrap failed — read/var/log/mysql/error.logbefore doing anything else. -
Start MariaDB normally on the second and third nodes. Each will pull an SST from the first node on first start.
sudo systemctl start mariadb sudo journalctl -u mariadb -f -
After all three are up, confirm the cluster from any node.
SHOW STATUS LIKE 'wsrep_cluster_size'; -- expect 3 SHOW STATUS LIKE 'wsrep_cluster_status'; -- expect Primary SHOW STATUS LIKE 'wsrep_local_state_comment'; -- expect Synced SHOW STATUS LIKE 'wsrep_evs_state'; -- expect OPERATIONAL
Common pitfalls
- Running
galera_new_clustermore than once — only the first node, only at cluster birth. Running it again on a healthy cluster splits the node off into a new one-node cluster. - Two-node clusters — they cannot reach quorum on partition; one node will go non-Primary and refuse writes. Use three or five, never two.
- Writes to all nodes without an auto-increment offset —
innodb_autoinc_lock_mode=2is mandatory; without it writes serialize and the cluster becomes a slow single-master. - SST over a flaky link —
mariabackupSST streams the full dataset; on a 500 GB database a hiccup mid-transfer means starting over. Run state transfers on the cluster’s private network, not the public one. - Forgetting
wsrep_sst_authon a joining node — the join will fail authentication and the node will sit inJoiningforever. The SST credentials must exist on the donor.
A Galera cluster is unforgiving when its operational discipline slips — the first time someone restarts the wrong node first after a full outage, the cluster does not come back. In the engagements we run, Galera lives under our managed operations practice: bootstrap order is documented and rehearsed, wsrep_* metrics feed Prometheus, and the proxy in front of it (ProxySQL or MaxScale) is configured to route around a non-Synced node before the application notices. For the broader pattern of operating clustered databases like this, see /en/solutions/clustered-environments/.