On occasion, you may have the need to restart a Galera Cluster. This could be part of a maintenance procedure, system/node recovery after a power failure, or for another reason. Before proceeding, please take a backup of your database to prevent any potential data loss. Also, ensure that all your nodes have the same configuration and are connected within the same network.
Table of Contents
When is a Galera Cluster Restart Necessary
Here are a few examples of why you may need to restart a Galera Cluster. This can of course vary depending on your use case.
- Software Updates or Patches: Restarting the cluster may be necessary after installing updates or patches to MariaDB or the underlying operating system to ensure changes take effect.
- Hardware Maintenance or Upgrade: If you are performing maintenance or upgrading hardware resources on the servers hosting the Galera nodes, you may need to restart the cluster.
- Configuration Changes: Changes made to the MariaDB configuration file typically require a cluster restart to apply.
- Network Issues: In case of severe network issues or changes in network configuration that disrupt the cluster communication, a cluster restart may be necessary.
- System Crash or Power Outage: If the system hosting the Galera nodes experiences a crash or power outage, a cluster restart will likely be necessary once the system is back online.
Steps to Restart a Galera Cluster
Step 1: Shutdown all nodes
The first step is to shut down all nodes in your Galera Cluster. You can do this by logging into each server that hosts a node and using the
systemctl command if your operating system uses systemd (like Ubuntu, Debian, CentOS, etc).
sudo systemctl stop mariadb
Step 2: Start the first node
The next step is to start the first node of your cluster, also referred to as the primary component. This node is started in a special way to signal that it should create a new cluster.
This command will start the first node of your MariaDB Galera Cluster and create a new cluster. You should run this command on only one of your nodes.
Step 3: Start the remaining nodes
Once the first node is up and running, you can start the other nodes normally. This can be done with the
systemctl command again.
sudo systemctl start mariadb
Repeat this on each remaining node in the cluster.
Step 4: Verify the cluster status
The final step is to verify that all nodes have joined the cluster and that the cluster is functioning correctly. This can be done by checking the value of the
wsrep_cluster_size status variable, which indicates the number of nodes in the cluster.
SHOW STATUS LIKE 'wsrep_cluster_size';
The value of
wsrep_cluster_size should be equal to the number of nodes in your cluster.
That’s it! Your MariaDB Galera Cluster should be up and running again. If you encounter any issues, check the error logs for each node. They can usually be found in the
/var/log/mysql/ directory or as per your configured
log_error path in the MariaDB configuration file.