At Vettabase, we’re starting a new blog series on High Availability (HA) with focus on MariaDB Galera Cluster. This series will be a collection of hands-on guides, each tackling one practical topic: from installation, configuration, and adding or removing nodes, to backups, upgrades, and schema changes.
Our goal is simple: create a complete, practical reference that anyone can follow to deploy and maintain a resilient MariaDB Galera cluster.
Each article will be concise, command-driven, and easy to reproduce on your own servers and this first post covers the foundation: installing a 3-node MariaDB Galera Cluster on Ubuntu 24.04 LTS.
Environment Setup
For this setup, we used three AWS EC2 instances (each t3.micro, Free Tier) running Ubuntu 24.04 LTS. Each host is configured for SSH key–based access and passwordless sudo privileges:
ssh -i <my-ssh-key> ubuntu@<Public IP address>
List of nodes:
- Galera1: 172.31.2.197
- Galera2: 172.31.3.237
- Galera3: 172.31.0.181
Galera Architecture Overview
MariaDB Galera Cluster is a multi-primary virtually synchronous replication system. That means all nodes (called Galera nodes) can accept both reads and writes, and every transaction is replicated to all others in real time.
Key concepts to understand before setup:
- Cluster: a group of nodes communicating via the gcomm:// protocol.
- Primary Component: the active group of nodes that can process writes.
- SST (State Snapshot Transfer): a full data copy from one node to another when a new node joins the cluster.
- IST (Incremental State Transfer): a sync of only recent changes.
- Bootstrap: the initial action of starting the first node in a Galera cluster. It creates the primary component and defines the cluster’s initial state. Only one node should ever be bootstrapped. All other nodes must join it.
Galera’s Quorum
Installation
The installation process is well documented on the official MariaDB documentation, and we’ll be following those steps here.
Run the following commands on each node:
curl -LsSO https://r.mariadb.com/downloads/mariadb_repo_setup
checksum=923eea378be2c129adb4d191f01162c1fe5473f1114d7586f096b5f6b9874efe
echo "${checksum} mariadb_repo_setup" | sha256sum -c -
mariadb_repo_setup: OK
chmod +x mariadb_repo_setup
Adding the MariaDB 11.8 Repository
sudo ./mariadb_repo_setup --mariadb-server-version="mariadb-11.8"
[info] Checking for script prerequisites. [info] MariaDB Server version 11.8 is valid [info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list [info] Adding trusted package signing keys... [info] Running apt-get update... [info] Done adding trusted package signing keys
Install the Required Packages
sudo apt install mariadb-server mariadb-client mariadb-backup galera-4 -y
- mariadb-server: main database engine
- mariadb-client: client tools (mysql, mariadb, etc.)
- mariadb-backup: backup utility
- galera-4: synchronous replication provider for the Galera cluster
Secure the MariaDB Installation
sudo mariadb-secure-installation
- Switch to unix_socket authentication – (recommended: Yes)
- Remove anonymous users – (Yes)
- Disallow root login remotely – (Yes)
- Remove test database – (Yes)
- Reload privilege tables – (Yes)
Configure the First (Bootstrap) Node
- Galera1: 172.31.2.197 (bootstrap node)
- Galera2: 172.31.3.237
- Galera3: 172.31.0.181
Minimal Configuration
- /etc/mysql/my.cnf
[mariadbd] # Basic settings binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 log_error=/var/log/mysql/mariadb.errsocket=/run/mysqld/mysqld.sock # Innodb innodb_force_primary_key=1 # Galera settings wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_cluster_name="<your cluster name>" wsrep_cluster_address="gcomm://<comma separated list of Galera Cluster IPs>" # Node identity (change per node) wsrep_node_name=<node name> wsrep_node_address="<node IP>" # SST configuration wsrep_sst_method=mariabackup wsrep_sst_auth="sstuser:sstpassword"
- wsrep_on – enables Galera replication.
- wsrep_provider – path to the Galera library (libgalera_smm.so), required for replication to function.
- wsrep_cluster_name – logical name of the cluster; all nodes must use the same name.
- wsrep_cluster_address – list of all cluster node IPs separated by commas in the format `gcomm://IP1,IP2,IP3`. During bootstrap, this list tells Galera which nodes to contact.
- wsrep_node_name – a unique name for the node within the cluster.
- wsrep_node_address – the IP address used for replication traffic.
- wsrep_sst_method – defines the method for State Snapshot Transfer (SST) – the process of copying full data from one node to another.
- rsync – simple and easy to configure.
- mariabackup – preferred for large datasets (non-blocking, hot backup).
- wsrep_sst_auth – credentials used by the donor node during SST.
- Format: “username:password”.
- This user must have privileges: RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT.
Add innodb_force_primary_key=1 to ensure all InnoDB tables have a primary key, as Galera requires PKs for consistent row replication and to prevent write conflicts or data divergence.
- /etc/mysql/my.cnf
[mariadbd] # Basic settings binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 log_error=/var/log/mysql/mariadb.err socket=/run/mysqld/mysqld.sock # Innodb innodb_force_primary_key=1 # Galera settings wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_cluster_name="vettabase_galera" wsrep_cluster_address="gcomm://172.31.2.197,172.31.3.237,172.31.0.181" # Node identity wsrep_node_name=galera1 wsrep_node_address="172.31.2.197" # SST configuration wsrep_sst_method=mariabackup wsrep_sst_auth="sst_user:sst_password"
Bootstrap the First Node
sudo systemctl stop mariadb sudo galera_new_cluster
sudo systemctl status mariadb
mariadb -u root -p -S /run/mysqld/mysqld.sock \ -e "SHOW GLOBAL STATUS LIKE 'wsrep%'" \ | grep -E "^wsrep_(cluster_size|cluster_status|local_state_comment|ready)"
wsrep_local_state_comment Synced wsrep_cluster_size 1 wsrep_cluster_status Primary wsrep_ready ON
- wsrep_local_state_comment = Synced: the node is operational and ready.
- wsrep_cluster_size = 1: the node has formed a cluster.
- wsrep_cluster_status = Primary: the cluster has quorum.
- wsrep_ready = ON: the node can accept queries.
Create the SST User
mariadb -u root -p -S /run/mysqld/mysqld.sock
CREATE USER 'sst_user'@'%' IDENTIFIED BY 'sst_password'; GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sst_user'@'%'; FLUSH PRIVILEGES;
Once created, the node is fully ready to act as an SST donor and replicate data to other cluster members.
Joining the Remaining Nodes
Verify Configuration on Each Node
- The IP list in wsrep_cluster_address contains all three nodes.
- Each node has its own unique wsrep_node_name and wsrep_node_address.
- The same wsrep_cluster_name and wsrep_sst_auth credentials are used as on Galera1.
wsrep_node_name=galera2 wsrep_node_address="172.31.3.237"
wsrep_node_name=galera2 wsrep_node_address="172.31.0.181"
Start MariaDB on Each Node
sudo systemctl restart mariadb
WSREP: Server galera1 synced with group WSREP: Server status change joined -> synced WSREP: Synchronized with group, ready for connections WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 0, memb_num = 2 WSREP: IST request ... tcp://172.31.3.237:4568 WSREP: 1.0 (galera2): State transfer from 0.0 (galera1) complete. WSREP: Member 1.0 (galera2) synced with group.
Galera Health Check
mariadb -u root -p -S /run/mysqld/mysqld.sock \ -e "SHOW GLOBAL STATUS LIKE 'wsrep%'" \ | grep -E "^wsrep_(cluster_size|cluster_status|local_state_comment|ready)"
wsrep_local_state_comment Synced wsrep_cluster_size 3 wsrep_cluster_status Primary wsrep_ready ON






0 Comments