Galera is an open-source synchronous multi-master replication technology that plays a pivotal role in database scaling and high availability. By enabling multiple database nodes to work together in a cluster, Galera ensures that data changes made on one node are instantaneously replicated to all others, offering real-time consistency across the cluster. This synchronous replication not only enhances data redundancy and fault tolerance but also enables seamless horizontal scaling, allowing organizations to meet growing demands for application performance and data availability. Galera's robust and straightforward approach to clustering makes it a valuable asset for scaling relational databases like MySQL and MariaDB while maintaining data integrity and reliability.


Setting up a MariaDB Galera Cluster involves configuring multiple MariaDB servers to work together as a cluster, ensuring high availability and data synchronization. Here's a step-by-step tutorial on how to enable Galera in MariaDB and set up a cluster:

Note: Before proceeding, ensure you have multiple servers running MariaDB, preferably on separate machines or virtual instances, with network connectivity between them.

Step 1: Install MariaDB

Make sure you have MariaDB installed on all the servers that will be part of the cluster. You can install MariaDB using the package manager for your operating system (e.g., apt for Ubuntu, yum for CentOS, or download from the MariaDB website).

Step 2: Configure MariaDB

Edit the MariaDB configuration file (my.cnf) on all cluster nodes. You'll need to make the following changes:

  1. Enable Galera Cluster: Add or modify the following lines in the [mysqld] section of the my.cnf file:

    • Replace node1_ip, node2_ip, etc., with the IP addresses of your cluster nodes.
    • Set a unique name for each node using wsrep_node_name.
    • Adjust the wsrep_sst_method based on your preference and security requirements (rsync is simple but may not be the most efficient).
  2. Set Galera Options: Add the following lines to the [galera] section of the my.cnf file:


Step 3: Initialize the First Node

On one of the servers, initialize the cluster as the first node:

  1. Stop MariaDB: sudo systemctl stop mariadb

  2. Bootstrap the cluster:

    sudo galera_new_cluster

Step 4: Start MariaDB on Other Nodes

On the other nodes, start MariaDB with:

sudo systemctl start mariadb

Step 5: Verify Cluster Status

You can check the cluster status using the mysql command:

mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size';"

You should see a cluster size greater than 1, indicating that the nodes have formed a cluster.

Step 6: Test Failover

To test failover, you can stop the MariaDB service on one of the nodes and ensure that the cluster continues to operate with the remaining nodes.

Step 7: Configure Your Applications

Update your applications to connect to the MariaDB Galera Cluster by specifying the IP addresses or hostnames of all the cluster nodes in the connection settings.

That's it! You've successfully set up a MariaDB Galera Cluster for high availability and data synchronization. Make sure to regularly monitor your cluster's health and performance, and consider implementing additional security measures, backup strategies, and automatic failover solutions for production environments.