Galera HA Cluster

Galera Cluster turns several MariaDB servers into one database with synchronous multi-master replication. Every committed transaction exists on all nodes at the moment the commit returns. There’s no replication lag, no failover promotion, and no lost transactions when a node dies. Each node holds the full data set, and any node can serve reads and writes.

With three nodes, the cluster survives the loss of any one of them and keeps running automatically. The two survivors still form a majority (a quorum). A two-node cluster can’t do that safely, which is why three is the minimum for production.

This guide builds a three-node cluster, db-01, db-02 and db-03, on Debian 13. It:

  • Uses MariaDB 11.8 LTS with Galera 4 from the Debian archive
  • Encrypts everything: client connections, Galera replication traffic and full state transfers (SST)
  • Uses mariadb-backup for state transfers, authenticated through the Unix socket with no password in any config file
  • Enforces Galera-safe SQL with wsrep_mode (primary keys required, InnoDB only)
  • Exposes a wsrep-aware health check for HAProxy, so clients only reach synced nodes, with a single writer to avoid certification conflicts
  • Covers the dangerous parts properly: bootstrapping, full-cluster recovery, rolling upgrades and backups

Tested on: Debian 13 “trixie” with the Debian packages mariadb-server (11.8), galera-4 and mariadb-backup. All commands run as root. Commands marked (all nodes) run on db-01, db-02 and db-03.


Table of contents

  1. Placeholders
  2. How Galera works
  3. Prerequisites
  4. Install the packages
  5. Firewall
  6. TLS certificates
  7. The cluster configuration
  8. Bootstrap the cluster
  9. Join the other nodes
  10. A wsrep-aware health check
  11. Load balancing with HAProxy
  12. Testing
  13. Monitoring
  14. Backups
  15. Day-2 operations
  16. Recovering from a full cluster outage
  17. Galera’s limitations
  18. Troubleshooting
  19. Checklist

1. Placeholders

PlaceholderMeaning
db-01.example.org / 10.20.0.31Node 1 (bootstraps the cluster)
db-02.example.org / 10.20.0.32Node 2
db-03.example.org / 10.20.0.33Node 3
10.20.10.0/24Application servers / HAProxy hosts that may connect to MariaDB
prod-dbThe cluster name (identical on all nodes)

2. How Galera works

ConceptWhat it means for you
Synchronous replicationAt commit, the transaction’s changes (its write set) are sent to all nodes, which certify it. Either all commit or none. No node ever lags behind in committed data.
Certification conflictsTwo nodes changing the same row at the same time: the transaction that arrives second is rolled back with a deadlock error. Applications must retry, or (better) write through one node at a time (section 11).
Primary component and quorumOnly a group holding a majority of nodes stays writable. A node that loses contact with the majority refuses queries, so a split network can never produce two diverging databases.
IST (incremental state transfer)A node that was briefly away gets only the missing transactions from a peer’s cache (gcache). It’s fast.
SST (state snapshot transfer)A new node, or one away too long, gets a full copy of the database from a donor using mariadb-backup. It’s slow for big databases, so size gcache to make IST the normal case.
BootstrapThe very first start of a cluster, or after all nodes were down. Exactly one node starts a new cluster, and the others join it.
PortProtocolPurposeBetween
3306TCPClient SQL connectionsApplications and HAProxy โ†’ nodes
4567TCPGalera group communication and replicationNode โ†” node
4568TCPISTNode โ†” node
4444TCPSST (mariadb-backup over socat)Node โ†” node
9200TCPHealth check (section 10)HAProxy โ†’ nodes

3. Prerequisites

(all nodes)

  • Three separate failure domains. Different hypervisor hosts at least, and ideally different racks or power feeds. Three VMs on one host is a single point of failure with extra steps.
  • Low, stable latency between the nodes (same data centre, or metro distance). Every commit waits for the slowest node.
  • Resolvable names. All nodes resolve each other’s FQDNs (DNS, or /etc/hosts entries on every node).
  • Synchronised time (chrony), for sane logs and certificates.
  • Identical hardware sizing. The cluster runs at the speed of its slowest node.

4. Install the packages

(all nodes)

apt update
apt install mariadb-server galera-4 mariadb-backup socat
PackagePurpose
mariadb-serverMariaDB 11.8 LTS
galera-4The replication library (/usr/lib/galera/libgalera_smm.so)
mariadb-backupHot physical copies, used for SST and for your backups
socatTransports SST data between nodes, with TLS

Debian starts MariaDB right after installation as a stand-alone server. Stop it on all nodes before configuring the cluster:

systemctl stop mariadb

5. Firewall

(all nodes) Only the other cluster nodes may reach the Galera ports. Only the application network may reach SQL and the health check. Create /etc/nftables.d/galera.nft:

destroy table inet galera
table inet galera {
    set nodes_v4 {
        type ipv4_addr
        elements = { 10.20.0.31, 10.20.0.32, 10.20.0.33 }
    }
    set clients_v4 {
        type ipv4_addr
        flags interval
        elements = { 10.20.10.0/24 }
    }

    chain input {
        type filter hook input priority filter - 10; policy accept;

        iif "lo" accept

        # Galera replication, IST and SST: cluster nodes only
        tcp dport { 4567, 4568, 4444 } ip saddr @nodes_v4 accept
        tcp dport { 4567, 4568, 4444 } counter drop
        udp dport 4567 counter drop

        # SQL and health check: application network and the nodes themselves
        tcp dport { 3306, 9200 } ip saddr { @clients_v4, @nodes_v4 } accept
        tcp dport { 3306, 9200 } counter drop
    }
}Code language: PHP (php)
nft -c -f /etc/nftables.conf && systemctl reload nftables
nft list table inet galeraCode language: PHP (php)

If your main /etc/nftables.conf still begins with flush ruleset, this file works as is. If you’ve replaced it with destroy table lines (as described in my Fail2Ban post), the destroy table inet galera line at the top keeps reloads idempotent.


6. TLS certificates

Every node needs a server certificate signed by your internal CA. The same certificate secures client connections, Galera replication and SST. My separate post MariaDB on Debian 13: TLS with your own CA shows how to create the CA and certificates. Issue one per node, with all names and the IP address of that node in the subjectAltName:

subjectAltName = DNS:db-01.example.org, DNS:db-01, IP:10.20.0.31

Place the files on each node:

install -d -m 0750 -o root -g mysql /etc/mysql/ssl
install -m 0644 -o root -g mysql ca.crt          /etc/mysql/ssl/ca.crt
install -m 0644 -o root -g mysql db-01.crt       /etc/mysql/ssl/server.crt
install -m 0640 -o root -g mysql db-01.key       /etc/mysql/ssl/server.key

(Use each node’s own certificate and key, under the same file names.)


7. The cluster configuration

(all nodes) Debian ships a commented-out template, /etc/mysql/mariadb.conf.d/60-galera.cnf. Leave it alone and add a file that sorts after it. Create /etc/mysql/mariadb.conf.d/65-galera-cluster.cnf (change the three node-specific lines on each node):

[mariadbd]
# --- Network -----------------------------------------------------------------------
# This node's LAN address (Debian's default is 127.0.0.1 only)
bind-address = 10.20.0.31

# --- TLS for clients, replication and SST ------------------------------------------
ssl-ca   = /etc/mysql/ssl/ca.crt
ssl-cert = /etc/mysql/ssl/server.crt
ssl-key  = /etc/mysql/ssl/server.key
tls_version = TLSv1.2,TLSv1.3
require_secure_transport = ON

# --- Settings Galera requires --------------------------------------------------------
binlog_format = ROW
default_storage_engine = InnoDB
innodb_autoinc_lock_mode = 2

# --- Sizing (adjust: roughly 50-70% of RAM on a dedicated DB server) -----------------
innodb_buffer_pool_size = 4G

[galera]
wsrep_on = ON
wsrep_provider = /usr/lib/galera/libgalera_smm.so

# --- Cluster membership ------------------------------------------------------------
wsrep_cluster_name    = prod-db
wsrep_cluster_address = gcomm://db-01.example.org,db-02.example.org,db-03.example.org

# --- This node (CHANGE PER NODE) -----------------------------------------------------
wsrep_node_name    = db-01
wsrep_node_address = 10.20.0.31

# --- Encrypt Galera replication with the server certificate --------------------------
wsrep_ssl_mode = SERVER_X509

# --- State transfer: mariadb-backup, authenticated via the Unix socket ---------------
wsrep_sst_method = mariabackup
wsrep_sst_auth   = mysql:

# --- Galera-safe SQL only ------------------------------------------------------------
wsrep_mode = REQUIRED_PRIMARY_KEY,STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY

# --- Performance ---------------------------------------------------------------------
wsrep_applier_threads = 4
# A big gcache makes IST possible after longer outages instead of a full SST
wsrep_provider_options = "gcache.size=2G; gcache.recover=yes"

[sst]
# Encrypt SST traffic and verify the peer against the CA
ssl-mode = VERIFY_CACode language: PHP (php)
SettingWhy
binlog_format = ROW, innodb_autoinc_lock_mode = 2Required by Galera: replication is row-based, and interleaved auto-increment locking prevents deadlocks
wsrep_cluster_addressAll three nodes, by name. A node ignores its own entry, so the line is identical everywhere.
wsrep_ssl_mode = SERVER_X509Encrypts replication with the server certificate from [mariadbd] and verifies peers against the CA. A node without a valid certificate can’t join.
wsrep_sst_auth = mysql:SST runs as the mysql system user. MariaDB’s built-in mysql@localhost account authenticates through the Unix socket, so no password exists anywhere.
[sst] ssl-mode = VERIFY_CAThe full database copy travels over TLS (socat), and the peer must hold a CA-signed certificate
wsrep_mode = REQUIRED_PRIMARY_KEYTables without a primary key replicate badly (full-table scans on every node), so they’re refused
wsrep_mode = STRICT_REPLICATIONRejects operations Galera can’t replicate safely, such as DDL on non-InnoDB tables
gcache.size=2GThe ring buffer of recent write sets. It must hold all changes during a typical node outage (a reboot or patch window) to allow IST instead of SST.
gcache.recover=yesKeeps the gcache across restarts, so IST works after a restart too
require_secure_transport = ONClients must use TLS. Local Unix-socket connections are still allowed.

Check that the built-in SST account exists. MariaDB creates it on new installs. Do this on db-01, starting MariaDB briefly as a stand-alone server:

mariadb -e "SHOW GRANTS FOR 'mysql'@'localhost';"Code language: JavaScript (javascript)

It should show IDENTIFIED VIA unix_socket (or similar) with full privileges. If the account is missing, create it:

CREATE USER 'mysql'@'localhost' IDENTIFIED VIA unix_socket;
GRANT RELOAD, PROCESS, LOCK TABLES, BINLOG MONITOR ON *.* TO 'mysql'@'localhost';Code language: JavaScript (javascript)

Then systemctl stop mariadb again.


8. Bootstrap the cluster

On db-01 only. Start a new cluster:

galera_new_cluster

galera_new_cluster starts MariaDB with --wsrep-new-cluster, which forms a new primary component instead of looking for peers. Never run it on more than one node, and never while a cluster is still running elsewhere. Doing so creates two independent clusters that diverge (a split-brain).

mariadb -e "SHOW GLOBAL STATUS WHERE Variable_name IN
  ('wsrep_cluster_size','wsrep_cluster_status','wsrep_local_state_comment','wsrep_ready');"Code language: PHP (php)
wsrep_cluster_size          1
wsrep_cluster_status        Primary
wsrep_local_state_comment   Synced
wsrep_ready                 ON

9. Join the other nodes

On db-02, then db-03, one at a time. A normal start makes the node contact the cluster address, receive an SST from db-01 (its local data directory is replaced), and join:

systemctl start mariadb
journalctl -u mariadb -f       # watch the SST; Ctrl+C when "Synced"Code language: PHP (php)

Wait until each node reports Synced before starting the next one. Then, on any node:

mariadb -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';"     # 3
mariadb -e "SHOW GLOBAL STATUS LIKE 'wsrep_incoming_addresses';"Code language: PHP (php)

Finally, restart db-01 once with a normal systemctl restart mariadb, so it runs as a regular member and not as the bootstrap node. It rejoins through IST within seconds.

From now on, all three nodes start normally with systemctl start mariadb. Bootstrapping is only needed again after all nodes were down (section 16).


10. A wsrep-aware health check

A plain TCP or MySQL login check says “up” for a node that’s joining, acting as an SST donor, or cut off from the quorum. Clients would then hit a node that blocks or refuses queries. A proper check asks Galera: is this node synced and ready?

(all nodes) Create a system user and a matching passwordless database account that only sees status:

useradd --system --no-create-home --shell /usr/sbin/nologin galerahealth
mariadb -e "CREATE USER IF NOT EXISTS 'galerahealth'@'localhost' IDENTIFIED VIA unix_socket;"Code language: JavaScript (javascript)

Only run the CREATE USER on one node. Galera replicates it to the others.

The check script, /usr/local/bin/galera-health:

#!/bin/sh
# Answers HTTP 200 if this Galera node is Synced and ready, 503 otherwise.
read -r _ 2>/dev/null   # consume the request line
status=$(mariadb -N -B -e "SHOW GLOBAL STATUS WHERE Variable_name IN ('wsrep_local_state','wsrep_ready')" 2>/dev/null)
state=$(echo "$status" | awk '$1=="wsrep_local_state"{print $2}')
ready=$(echo "$status" | awk '$1=="wsrep_ready"{print $2}')

if [ "$state" = "4" ] && [ "$ready" = "ON" ]; then
    printf 'HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 7\r\nConnection: close\r\n\r\nSynced\n'
else
    printf 'HTTP/1.1 503 Service Unavailable\r\nContent-Type: text/plain\r\nContent-Length: 11\r\nConnection: close\r\n\r\nNot synced\n'
fiCode language: PHP (php)
chmod 0755 /usr/local/bin/galera-health

Serve it with systemd socket activation. No extra daemon is needed, and each connection runs the script once, sandboxed. Create /etc/systemd/system/galera-health.socket:

[Unit]
Description=Galera health check socket

[Socket]
ListenStream=9200
Accept=yes

[Install]
WantedBy=sockets.target

And /etc/systemd/system/galera-health@.service:

[Unit]
Description=Galera health check

[Service]
ExecStart=/usr/local/bin/galera-health
StandardInput=socket
StandardOutput=socket
User=galerahealth
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yesCode language: JavaScript (javascript)
systemctl daemon-reload
systemctl enable --now galera-health.socket
curl -s -i http://localhost:9200/ | head -n 1      # HTTP/1.1 200 OKCode language: JavaScript (javascript)

wsrep_local_state = 4 means Synced. Every other state (joining, donor, joined but not caught up) answers 503.


11. Load balancing with HAProxy

Any node can accept writes, but writing to several nodes at once causes certification conflicts as soon as two transactions touch the same rows. The robust pattern is one writer at a time, with automatic failover: HAProxy sends all traffic to db-01 and switches to db-02 or db-03 only when db-01’s health check fails.

On the HAProxy hosts (often the application servers themselves), add to /etc/haproxy/haproxy.cfg:

listen galera
    bind 127.0.0.1:3306
    mode tcp
    option tcpka
    timeout client 8h
    timeout server 8h

    option httpchk
    http-check expect status 200
    default-server check port 9200 inter 2s fall 3 rise 2 on-marked-down shutdown-sessions

    server db-01 10.20.0.31:3306
    server db-02 10.20.0.32:3306 backup
    server db-03 10.20.0.33:3306 backupCode language: CSS (css)
SettingWhy
backup on db-02 and db-03Single writer: they get traffic only when db-01 is down or not synced
check port 9200 + httpchkUses the wsrep-aware check from section 10, not just a TCP connect
on-marked-down shutdown-sessionsConnections to a node that fails are cut immediately, so applications reconnect to the new writer instead of hanging
timeout client/server 8hLong-lived application connection pools aren’t killed by idle timeouts

Applications connect to 127.0.0.1:3306 on their own host, with TLS and the database server names in their CA trust. The TLS session runs end-to-end through HAProxy (mode tcp), so the certificate the client sees is that of the node it reaches. That’s why every node’s certificate is signed by the same CA.

Read scaling: for read-heavy workloads, add a second listen block on another port that balances reads across all three nodes (balance leastconn, no backup). Point only read-only connections at it.


12. Testing

12.1 Replication

# On db-01
mariadb -e "CREATE DATABASE galera_test;
  CREATE TABLE galera_test.t (id INT PRIMARY KEY, note VARCHAR(50));
  INSERT INTO galera_test.t VALUES (1, 'written on db-01');"

# On db-03
mariadb -e "INSERT INTO galera_test.t VALUES (2, 'written on db-03');
  SELECT * FROM galera_test.t;"      # both rows, immediatelyCode language: PHP (php)

12.2 wsrep_mode protection

mariadb -e "CREATE TABLE galera_test.nopk (v INT);"Code language: JavaScript (javascript)

The statement must be refused, with an error that names REQUIRED_PRIMARY_KEY.

12.3 Losing one node

systemctl stop mariadb                                         # on db-02
mariadb -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';"     # on db-01: 2
mariadb -e "INSERT INTO galera_test.t VALUES (3, 'during outage');"   # still works
systemctl start mariadb                                        # on db-02
journalctl -u mariadb | grep -iE 'IST|SST' | tail -n 5          # "IST received", not a full SSTCode language: PHP (php)

12.4 Losing the quorum

Stop MariaDB on two nodes. The last node detects that it holds only a minority:

mariadb -e "SELECT 1;"
# ERROR 1047 (08S01): WSREP has not yet prepared node for application useCode language: PHP (php)

That’s the cluster protecting your data, not a bug. Start the other nodes again, and it recovers on its own.

12.5 Encryption

# Replication and SST use TLS: no plaintext SQL visible in the traffic
mariadb -e "SHOW GLOBAL VARIABLES LIKE 'wsrep_ssl_mode';"      # SERVER_X509
openssl s_client -starttls mysql -connect db-01.example.org:3306 \
  -CAfile /etc/mysql/ssl/ca.crt </dev/null 2>/dev/null | grep -E 'Protocol|Verify return'Code language: PHP (php)

12.6 Failover through HAProxy

On an application host, run mariadb -h 127.0.0.1 -e "SELECT @@hostname;" (db-01). Then stop MariaDB on db-01 and repeat. Within about 6 seconds the answer is db-02 or db-03.

Clean up with mariadb -e "DROP DATABASE galera_test;".


13. Monitoring

The status variables that matter, on every node:

VariableHealthy valueMeaning when it’s not
wsrep_cluster_size3A node is missing
wsrep_cluster_statusPrimaryThis node lost the quorum and refuses queries
wsrep_local_state_commentSyncedJoining, donor, or catching up
wsrep_readyONNot accepting queries
wsrep_connectedONNo connection to the group
wsrep_flow_control_pausedClose to 0.0A slow node is throttling the whole cluster
wsrep_local_recv_queue_avgBelow 1This node can’t apply write sets fast enough
mariadb -e "SHOW GLOBAL STATUS LIKE 'wsrep_%';" | grep -E 'cluster_size|cluster_status|state_comment|ready|connected|flow_control_paused|recv_queue_avg'Code language: JavaScript (javascript)

With Prometheus: the Debian package prometheus-mysqld-exporter exports all wsrep_* variables (as mysql_global_status_wsrep_*). Alert on these at least:

- alert: GaleraClusterSizeReduced
  expr: mysql_global_status_wsrep_cluster_size < 3
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: "Galera cluster on {{ $labels.instance }} sees only {{ $value }} nodes"

- alert: GaleraNodeNotReady
  expr: mysql_global_status_wsrep_ready != 1
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: "{{ $labels.instance }} doesn't accept queries (not synced or not in the primary component)"

- alert: GaleraFlowControlHigh
  expr: rate(mysql_global_status_wsrep_flow_control_paused_ns[5m]) / 1e9 > 0.1
  for: 10m
  labels:
    severity: warning
  annotations:
    summary: "Flow control pauses the cluster more than 10% of the time"Code language: JavaScript (javascript)

14. Backups

Galera is high availability, not backup. A DROP TABLE replicates to all nodes within milliseconds. Take real backups.

Run them on one node, ideally one of the HAProxy backup nodes, so the writer isn’t loaded:

TARGET=/var/backups/mariadb/$(date +%F_%H%M)
mariadb-backup --backup --galera-info --target-dir="$TARGET"
mariadb-backup --prepare --target-dir="$TARGET"Code language: JavaScript (javascript)

--galera-info stores the cluster position (xtrabackup_galera_info), so a restored node can rejoin through IST instead of a full SST. During the backup, the node’s health check stays green, but the node is busier. That’s why you don’t run it on the writer.

Test restores regularly. A backup that has never been restored is a hope, not a backup. Copy backups off the cluster, and keep at least one copy offline or immutable.


15. Day-2 operations

15.1 Rolling restarts and upgrades

Patch one node at a time and keep the quorum:

# On each node in turn, starting with a backup node, the writer last:
systemctl stop mariadb
apt upgrade                         # or reboot for a new kernel
systemctl start mariadb
mariadb -e "SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';"   # wait for "Synced"Code language: PHP (php)

Never take the next node down before the previous one is Synced again. The unattended-upgrades reboot window (see my unattended-upgrades post) must be staggered so the three nodes never restart at the same time.

15.2 Schema changes

DDL such as ALTER TABLE runs in Total Order Isolation by default: the whole cluster waits until it’s done. For big tables, use Rolling Schema Upgrade instead (SET SESSION wsrep_OSU_method='RSU';, run per node), or an online schema-change tool. Test on a copy first.

15.3 Adding or replacing a node

Install and configure it as in sections 4โ€“7, add its name to wsrep_cluster_address in the config file on all nodes, and systemctl start mariadb on the new node. It joins through SST. The running nodes don’t need a restart: the address list is only used when a node starts. Don’t change wsrep_cluster_address at runtime with SET GLOBAL, because that makes the node reconnect.


16. Recovering from a full cluster outage

After a power loss or a shutdown of all nodes, no node starts on its own, because none of them knows whether it holds the latest data. With pc.recovery (on by default), the cluster reassembles automatically if all nodes come back and can see each other. If it doesn’t, recover by hand:

1. Find the most advanced node. On every node:

cat /var/lib/mysql/grastate.datCode language: JavaScript (javascript)
# GALERA saved state
version: 2.1
uuid:    9b2f...
seqno:   1832471
safe_to_bootstrap: 1Code language: CSS (css)

The node with safe_to_bootstrap: 1 was the last one to leave the cluster. If every node shows seqno: -1 (a crash), ask each one for its last committed position:

galera_recovery        # prints e.g. --wsrep_start_position=9b2f...:1832471Code language: PHP (php)

2. Bootstrap from the node with the highest seqno. If its safe_to_bootstrap is 0, set it to 1 on that node only, then:

galera_new_cluster

3. Start the other nodes normally (systemctl start mariadb). They rejoin through IST or SST.

Bootstrapping from the wrong node loses the transactions that only the more advanced node had. Never set safe_to_bootstrap: 1 on more than one node.


17. Galera’s limitations

Know these before you migrate an application:

LimitationConsequence
InnoDB onlyMyISAM and Aria tables don’t replicate (STRICT_REPLICATION refuses changes to them)
Primary keys requiredEnforced by REQUIRED_PRIMARY_KEY in this setup
LOCK TABLES, GET_LOCK()Not supported cluster-wide
Huge transactionsWrite sets are limited (wsrep_max_ws_size, 2 GB). Batch big imports and deletes.
Write throughputDoesn’t scale with more nodes: every node applies every write. Galera scales reads and gives availability.
Commit latencyEvery commit waits for one network round trip to all nodes

18. Troubleshooting

SymptomCause / fix
Node won’t start: failed to reach primary viewNo other node reachable. Check the firewall (4567) and DNS. If all nodes are down, bootstrap (section 16).
It may not be safe to bootstrap the cluster from this nodesafe_to_bootstrap: 0. Find the most advanced node first (section 16), don’t just flip the flag.
SST fails, log shows socat or TLS errorsPorts 4444/4568 blocked, socat missing, or a certificate not signed by the shared CA
SST fails with authentication errorsThe mysql@localhost Unix-socket account is missing (section 7)
Joining node does a full SST after every restartgcache.size too small for the outage. Increase it.
Deadlock found when trying to get lock on commitCertification conflict from writing the same rows on several nodes. Use single-writer routing (section 11), and let the application retry.
Cluster gets slow, wsrep_flow_control_paused risesOne node is slower (disk, CPU, network). Find it via wsrep_local_recv_queue_avg.
ERROR 1047 WSREP has not yet prepared nodeThis node isn’t in the primary component (quorum lost) or is still syncing

19. Checklist

  • โ˜ Three nodes on separate hypervisor hosts, with low latency between them and identical sizing
  • โ˜ mariadb-server, galera-4, mariadb-backup and socat are installed on all nodes
  • โ˜ The firewall allows 4567/4568/4444 only between nodes, and 3306/9200 only from applications
  • โ˜ Every node has a CA-signed certificate with its names and IP in the SAN
  • โ˜ 65-galera-cluster.cnf is identical except for bind-address, wsrep_node_name and wsrep_node_address
  • โ˜ Client TLS is required, replication uses wsrep_ssl_mode = SERVER_X509, and SST uses [sst] ssl-mode = VERIFY_CA
  • โ˜ SST uses mariadb-backup with the Unix-socket mysql account, so there’s no password in any file
  • โ˜ wsrep_mode enforces primary keys and strict replication
  • โ˜ The cluster was bootstrapped once on db-01, all nodes are Synced, and wsrep_cluster_size = 3
  • โ˜ The health check on port 9200 answers 200 only when synced
  • โ˜ HAProxy routes to a single writer, with backups and fast failover
  • โ˜ Replication, single-node loss, quorum loss, IST and HAProxy failover were all tested
  • โ˜ Monitoring alerts on cluster size, primary status and flow control
  • โ˜ Backups with --galera-info run on a non-writer node, and restores are tested
  • โ˜ Patch reboots are staggered, and the full-outage recovery procedure is documented and rehearsed