How To Restart a Galera Cluster in 4 Easy Steps

galera cluster, mariadb, restart galery cluster

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.

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.

  1. 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.
  2. 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.
  3. Configuration Changes: Changes made to the MariaDB configuration file typically require a cluster restart to apply.
  4. Network Issues: In case of severe network issues or changes in network configuration that disrupt the cluster communication, a cluster restart may be necessary.
  5. 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.
restart galera cluster

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.

sudo galera_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.

See also  MySQL-Async: The Key to Faster, More Efficient Databases

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.

Support us & keep this site free of annoying ads.
Shop Amazon.com or Donate with Paypal

Leave a Comment