How can we help?
Categories
< All Topics
Print

Advanced Database Clustering with Galera Cluster for MySQL

Introduction

Implementing Galera Cluster for MySQL on ServerStadium’s infrastructure (VM Pricing, Dedicated Servers) enables businesses to manage large-scale, high-availability databases efficiently. Galera Cluster’s synchronous replication model ensures that data is consistent across all nodes, making it ideal for critical applications requiring high uptime and data integrity.

Prerequisites

  • ServerStadium VMs or dedicated servers (VM Pricing, Dedicated Servers)., ideally three for a basic cluster setup.
  • Basic knowledge of MySQL database administration.
  • SSH access to the servers.

Step 1: Set Up ServerStadium Environment

  1. Choose Servers: Select three or more ServerStadium servers to form a cluster.
  2. Prepare Servers:

    sudo apt update
    sudo apt upgrade

Step 2: Install MySQL and Galera on Each Node

  1. Install MySQL:

    Install MySQL on each server:

    sudo apt install mysql-server

  2. Install Galera:

    Install the Galera package:

    sudo apt install galera-4

Step 3: Configure MySQL for Galera Cluster

  1. Configure MySQL on Each Node:

    Edit the MySQL configuration file (/etc/mysql/my.cnf or similar) to enable Galera:

    sudo nano /etc/mysql/my.cnf

    Add the following under the [mysqld] section:

    [mysqld]
    wsrep_provider=/usr/lib/galera/libgalera_smm.so
    wsrep_cluster_name='galera_cluster'
    wsrep_cluster_address='gcomm://node1_ip,node2_ip,node3_ip'
    wsrep_node_address='this_node_ip'
    wsrep_sst_method=rsync


    Replace node1_ip, node2_ip, node3_ip, and this_node_ip with the actual IP addresses of your nodes.

Step 4: Initialize the Galera Cluster

  1. Start the First Node:

    On the first node, start the MySQL server with Galera initialization:

    sudo galera_new_cluster

  2. Start MySQL on Other Nodes:

    On the remaining nodes, start the MySQL service normally:

    sudo systemctl start mysql

Step 5: Verify Cluster Operation

  1. Check Cluster Size:

    Verify that the cluster is operational by checking the cluster size on any node:

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

Conclusion

Galera Cluster enhances MySQL’s capabilities on ServerStadium servers, providing a robust platform for high-availability database solutions. It’s an ideal setup for applications demanding high data integrity and minimal downtime. For advanced cluster configurations and management, visit our knowledge base or contact our support team.

Table of Contents