Setting up MariaDB Galera Cluster for High Availability

rohitjain25

Rohit Jain

Posted on February 4, 2023

Setting up MariaDB Galera Cluster for High Availability

Setting up MariaDB Galera Cluster for High Availability

MariaDB is an open-source relational database management system that is a fork of the popular MySQL database. It is designed to provide high availability and scalability for applications and services that require a highly available database backend.

In this blog, we will be discussing the setup of a MariaDB Galera Cluster, which is a multi-node database cluster that provides automatic failover and load balancing. With Galera Cluster, you can ensure that your database is always available, even in the event of a single node failure.

Prerequisites

  • At least three servers with MariaDB installed and configured
  • A shared storage system (such as NFS or GlusterFS) for storing the database files
  • Network connectivity between all nodes

Step 1: Configure Galera Replication on Each Node

On each node, open the MariaDB configuration file (my.cnf) and add the following lines:

[mysqld]
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://<IP1>,<IP2>,<IP3>"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
Enter fullscreen mode Exit fullscreen mode

Replace <IP1>, <IP2>, <IP3> with the IP addresses of your cluster nodes.

Step 2: Start the Cluster

On the first node, start MariaDB and initialize the Galera Cluster:

systemctl start mysql
galera_new_cluster
Enter fullscreen mode Exit fullscreen mode

Step 3: Join Additional Nodes

On the remaining nodes, start MariaDB and join the cluster:

SET GLOBAL wsrep_cluster_address = "gcomm://<IP1>,<IP2>,<IP3>";
Enter fullscreen mode Exit fullscreen mode

Step 4: Verify Cluster Status

To verify the status of your cluster, log in to MariaDB on any node and run the following command:

SHOW STATUS LIKE 'wsrep_cluster_size';
Enter fullscreen mode Exit fullscreen mode

The output should show the number of nodes in your cluster.

Conclusion

In this blog, we covered the steps to set up a MariaDB Galera Cluster for high availability. With Galera Cluster, you can ensure that your database is always available, even in the event of a single node failure. Whether you're running a small application or a large enterprise service, MariaDB Galera Cluster can help you achieve high availability and scalability for your database backend.

💖 💪 🙅 🚩
rohitjain25
Rohit Jain

Posted on February 4, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related