MariaDB 10.2 Xtrabackup Error: WSREP_SST_OPT_PORT: Unbound Variable - Explained

2024-07-27

  • MariaDB 10.2 Xtrabackup: This specifies the MariaDB version (10.2) and the tool being used for backup (Xtrabackup).
  • /usr/bin/wsrep_sst_xtrabackup-v2: This is the path to the script used for performing State Snapshot Transfer (SST) with Xtrabackup.
  • WSREP_SST_OPT_PORT: unbound variable: This is the core of the error message. It indicates that the script is trying to use an environment variable named WSREP_SST_OPT_PORT but this variable is not set.

What is WSREP_SST_OPT_PORT?

This environment variable likely controls a port number used during the MariaDB cluster State Snapshot Transfer (SST) process with Xtrabackup. SST allows a new node to join a Galera cluster by transferring the current state of the cluster from an existing member.

How to Fix the Error

To fix this error, you need to set the WSREP_SST_OPT_PORT environment variable before running the wsrep_sst_xtrabackup-v2 script. You can achieve this in two ways:

  1. Setting in Shell Environment:

    Open a terminal and run the following command to set the variable temporarily for your current shell session:

    export WSREP_SST_OPT_PORT=PORT_NUMBER
    

    Replace PORT_NUMBER with the actual port you want to use for the SST process.

  2. Setting in Script:

Additional Information:

  • It's important to choose a port number that is not being used by other applications on your system to avoid conflicts.



While not ideal for Galera clusters due to potential inconsistencies, here's an example of using xtrabackup for a full backup:

xtrabackup --backup --target-dir=/backup/mariadb_full_backup

This command creates a full backup of your MariaDB data directory in the /backup/mariadb_full_backup directory.

Using mariabackup (Recommended for MariaDB 10.2 and Later):

MariaDB introduced mariabackup as a more integrated and recommended alternative to Percona Xtrabackup. Here's an example:

mariabackup --backup --target-dir=/backup/mariadb_full_backup

This command functions similarly to the xtrabackup example but is the preferred method for MariaDB backups.

Galera Cluster SST with xtrabackup (Use with Caution):

Important Note: Due to potential inconsistencies, this approach should be used with caution and only if mariabackup is not an option. Refer to MariaDB documentation for supported methods for Galera cluster backups.

Here's a cautionary example using xtrabackup for a Galera cluster SST (State Snapshot Transfer):

# Stop slave threads (Optional, might be needed depending on your setup)
mysql -e 'STOP SLAVE;'

# Prepare for backup (Replace <source_server>, <destination_server> with actual hostnames)
xtrabackup --prepare --host=<source_server>

# Perform backup on source server
xtrabackup --backup --host=<source_server> --target-dir=/tmp/galera_sst_backup

# SCP backup directory to destination server (Replace user@destination_server with actual details)
scp -r /tmp/galera_sst_backup user@<destination_server>:/tmp/

# On destination server, prepare for SST using received backup
xtrabackup --prepare --apply-log --host=<destination_server> --xtrabackup-dir=/tmp/galera_sst_backup

# Start slave threads (Optional)
mysql -e 'START SLAVE;'



  • This method creates a text dump of your database schema and data.
  • It's a good choice for smaller databases or for backing up specific databases/tables.
  • However, restoring a complete database from a logical backup can be time-consuming.

Example:

mysqldump -u username -p database_name > /backup/mariadb_logical_backup.sql

Native MariaDB Backup with mariadb-backup (Recommended):

  • This is the preferred method for MariaDB backups, introduced in MariaDB 10.1.
  • It offers functionalities similar to Percona Xtrabackup but is specifically designed for MariaDB and handles features like compression and encryption.

Continuous Archiving with Tools like Myreplication:

  • This approach focuses on replicating ongoing database changes to a separate server for disaster recovery purposes.
  • Tools like Myreplication continuously stream database updates to a slave server, ensuring near real-time backups.
  • This method requires additional setup and management but offers a more robust solution for continuous data protection.

Choosing the Right Method:

The best method depends on your specific needs:

  • For quick backups of smaller databases, mysqldump might suffice.
  • For consistent, reliable backups with MariaDB-specific features, mariadb-backup is recommended.
  • For continuous data protection and disaster recovery, consider tools like Myreplication.

Additional Tips:

  • Regardless of the method, automate your backups to ensure regular and consistent data protection.
  • Store backups on a separate server or cloud storage for added security.
  • Regularly test your backups to ensure successful restores when needed.

mariadb



Understanding Example Codes for Granting All Privileges in MySQL/MariaDB

In simple terms, "granting all privileges on a database" in MySQL or MariaDB means giving a user full control over that specific database...


MAMP with MariaDB: Configuration Options

Stands for Macintosh Apache MySQL PHP.It's a local development environment that bundles Apache web server, MySQL database server...


MySQL 5 vs 6 vs MariaDB: Choosing the Right Database Server

The original open-source relational database management system (RDBMS).Widely used and considered the industry standard...


Beyond Backups: Alternative Approaches to MySQL to MariaDB Migration

There are two main approaches depending on your comfort level:Complete Uninstall/Install:Stop the MySQL server. Uninstall MySQL...


MySQL vs MariaDB vs Percona Server vs Drizzle: Choosing the Right Database

Here's an analogy: Imagine MySQL is a popular recipe for a cake.MariaDB would be someone taking that recipe and making a very similar cake...



mariadb

Understanding and Resolving MySQL Error 1153: Example Codes

Common Causes:Large Data Sets: When dealing with large datasets, such as importing a massive CSV file or executing complex queries involving many rows or columns


Speed Up Your Inserts: Multi-Row INSERT vs. Multiple Single INSERTs in MySQL/MariaDB

Reduced Overhead: Sending a single INSERT statement with multiple rows requires less network traffic compared to sending many individual INSERT statements


Understanding MySQL's SELECT * INTO OUTFILE LOCAL Statement

Functionality:This statement exports the results of a MySQL query to a plain text file on the server that's running the MySQL database


MariaDB for Commercial Use: Understanding Licensing and Support Options

Commercial License: Typically refers to a license where you pay a fee to use software for commercial purposes (selling a product that uses the software)


Fixing 'MariaDB Engine Won't Start' Error on Windows

MariaDB: An open-source relational database management system similar to MySQL.Windows: The operating system where MariaDB is installed