Manual SST of Galera Cluster Node With mariadb-backup
Perform a manual node provision. This guide details the steps to manually backup a donor and restore it to a joiner node in a Galera Cluster.
Sometimes it can be helpful to perform a "manual SST" when Galera's normal SSTs fail. This can be especially useful when the cluster's datadir is very large, since a normal SST can take a long time, keeping the donor in a not fully synced state for the duration of the transfer.
A manual SST essentially consists of taking a backup of the donor, loading the backup on the joiner, and then manually editing the cluster state on the joiner node. This page will show how to perform this process with mariadb-backup.
Process
Prepare and Transfer the Backup (Choose ONE Method)
Select the strategy below that best matches your environment's resource constraints and upgrade requirements.
Method A: Prepare on the Joiner Node (Standard / Resource-Saving)
Use this if both nodes are on the same major MariaDB version. This offloads RAM and CPU overhead from the active donor to the joiner.
On the donor node, create the backup directory and take the backup:
BACKUP_DIR=/mariadb_backup
mkdir -p $BACKUP_DIR
DB_USER=sstuser
DB_USER_PASS=password
mariadb-backup --backup --galera-info \
--target-dir=$BACKUP_DIR \
--user=$DB_USER \
--password=$DB_USER_PASSOn the joiner node, stop MariaDB, create the backup directory:
systemctl stop mariadb
BACKUP_DIR=/mariadb_backup
mkdir -p $BACKUP_DIRFrom the donor node, transfer the contents of the backup directory to the joiner node. You may use
rsync,scp, or your preferred file transfer method.On the joiner node, prepare the backup:
mariadb-backup --prepare --target-dir=$BACKUP_DIRMethod B: Prepare on the Donor Node (Required for Major Upgrades)
Use this for cross-version upgrades (e.g., 10.6 to 11.4). The donor's native binary must apply the redo logs before transit, ensuring compatibility.
1. On the donor node, create the directory, take the backup, and prepare it:
BACKUP_DIR=/mariadb_backup
mkdir -p $BACKUP_DIR
DB_USER=sstuser
DB_USER_PASS=password
mariadb-backup --backup --galera-info \
--target-dir=$BACKUP_DIR \
--user=$DB_USER \
--password=$DB_USER_PASS
mariadb-backup --prepare --target-dir=$BACKUP_DIR2. On the joiner node, make sure MariaDB is stopped, create the directory:
systemctl stop mariadb
BACKUP_DIR=/mariadb_backup
mkdir -p $BACKUP_DIRFrom the donor node, transfer the contents of the backup directory to the joiner node. You may use
rsync,scp, or your preferred file transfer method.
Method C: Streaming Backup (Zero Donor Disk Overhead)
Use this to avoid using local staging disk space on the donor node, especially when the cluster's datadir is very large. A standard manual backup requires enough free disk space on the donor node to hold a complete secondary copy of the data. Streaming avoids this local disk overhead entirely by piping the data directly over SSH
Do not use for cross-version upgrades.
On the joiner node, make sure MariaDB is stopped and create the target directory:
systemctl stop mariadb
BACKUP_DIR=/mariadb_backup
mkdir -p $BACKUP_DIR2. On the donor node, stream the backup directly to the joiner:
DB_USER=sstuser
DB_USER_PASS=password
OS_USER=dba
JOINER_HOST=dbserver2.mariadb.com
BACKUP_DIR=/mariadb_backup
mariadb-backup --backup --galera-info --stream=mbstream \
--user=$DB_USER --password=$DB_USER_PASS | \
ssh ${OS_USER}@${JOINER_HOST} "mbstream -x -C $BACKUP_DIR"3. On the joiner node, prepare the backup:
mariadb-backup --prepare --target-dir=$BACKUP_DIRFor example, a very common version number is "2.1".
Get the node's cluster state
Get the state from the Galera info file in the backup that was copied to the joiner node.
The name of this file depends on the MariaDB version:
MariaDB 11.4 and later:
mariadb_backup_galera_infoMariaDB 11.3 and earlier:
xtrabackup_galera_info
For MariaDB 11.4 and later:
cat $BACKUP_DIR/mariadb_backup_galera_infoFor MariaDB 11.3 and earlier:
cat $BACKUP_DIR/xtrabackup_galera_infoThe file contains the values of the wsrep_local_state_uuid and wsrep_last_committed status variables. The values are written in the following format:
wsrep_local_state_uuid:wsrep_last_committedFor example:
d38587ce-246c-11e5-bcce-6bbd0831cc0f:1352215Create a grastate.dat file
Create the file in the backup directory of the joiner node. The Galera Cluster version ID, the cluster uuid, and the seqno from previous steps will be used to fill in the relevant fields.
For example, with the example values from the last two steps, we could do:
sudo tee $BACKUP_DIR/grastate.dat <<EOF
# GALERA saved state
version: 2.1
uuid: d38587ce-246c-11e5-bcce-6bbd0831cc0f
seqno: 1352215
safe_to_bootstrap: 0
EOFRemove contents
Remove the existing contents of the datadir on the joiner node.
DATADIR=/var/lib/mysql
rm -Rf $DATADIR/*Copy contents
Copy the contents of the backup directory to the datadir the on joiner node.
mariadb-backup --copy-back \
--target-dir=$BACKUP_DIRCheck datadir permissions
Make sure the permissions of the datadir are correct on the joiner node.
chown -R mysql:mysql $DATADIR/Start the MariaDB Server process on the joiner node.
This will depend on your service manager. For example, on systemd systems, you may execute::
systemctl start mariadbWatch the MariaDB error log
On the joiner node, verify that the node does not need to perform a normal SSTs due to the manual SST.
tail -f /var/log/mysql/mysqld.logThis page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

