Docs / Databases / How to Set Up MariaDB Galera Cluster

How to Set Up MariaDB Galera Cluster

By Admin · Mar 2, 2026 · Updated Apr 24, 2026 · 31 views · 3 min read

How to Set Up MariaDB Galera Cluster

MariaDB Galera Cluster provides synchronous multi-master replication, meaning every node can accept both reads and writes with automatic conflict resolution. This setup gives you true high availability across your Breeze instances with no single point of failure.

Prerequisites

You need at least three Breeze instances to form a proper cluster (an odd number prevents split-brain). Each node must run the same version of MariaDB and have network access between them on ports 3306, 4567 (Galera replication), 4568 (IST), and 4444 (SST).

Installing MariaDB with Galera

On each Breeze instance running Ubuntu:

sudo apt update
sudo apt install -y mariadb-server galera-4

Stop MariaDB before configuring the cluster:

sudo systemctl stop mariadb

Cluster Configuration

Create /etc/mysql/mariadb.conf.d/99-galera.cnf on each node:

[mysqld]
binlog_format = ROW
default_storage_engine = InnoDB
innodb_autoinc_lock_mode = 2
innodb_flush_log_at_trx_commit = 0
innodb_buffer_pool_size = 512M

# Galera settings
wsrep_on = ON
wsrep_provider = /usr/lib/galera/libgalera_smm.so
wsrep_cluster_name = "breeze_cluster"
wsrep_cluster_address = "gcomm://breeze1-ip,breeze2-ip,breeze3-ip"
wsrep_node_address = "this-breeze-ip"
wsrep_node_name = "breeze1"
wsrep_sst_method = mariabackup
wsrep_sst_auth = "sst_user:SSTpassword123!"

Adjust wsrep_node_address and wsrep_node_name for each node.

Creating the SST User

Start MariaDB temporarily on one node to create the State Snapshot Transfer user:

sudo systemctl start mariadb
mysql -u root -e "
CREATE USER 'sst_user'@'localhost' IDENTIFIED BY 'SSTpassword123!';
GRANT RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sst_user'@'localhost';
FLUSH PRIVILEGES;"
sudo systemctl stop mariadb

Bootstrapping the Cluster

On the first node only, bootstrap the cluster:

sudo galera_new_cluster

Verify it is running:

mysql -u root -e "SHOW STATUS LIKE 'wsrep_cluster_size';"

You should see wsrep_cluster_size = 1.

Joining Additional Nodes

On each remaining Breeze instance, simply start MariaDB:

sudo systemctl start mariadb

The node will automatically join the cluster and synchronize data via SST. Check the cluster size increases with each new node.

Monitoring Cluster Health

Key status variables to monitor:

SHOW STATUS LIKE 'wsrep_%';

-- Important variables:
-- wsrep_cluster_size    = number of nodes
-- wsrep_cluster_status  = Primary (healthy)
-- wsrep_ready           = ON
-- wsrep_connected       = ON
-- wsrep_local_state_comment = Synced

If wsrep_local_recv_queue_avg is consistently above 0.5, your node is falling behind and you may need to tune wsrep_slave_threads or upgrade your Breeze instance resources.

Was this article helpful?