🎖️[Easy] How to install, configure and test a 2 Node Mariadb 10.6 Galera Cluster on Ubuntu 22.04



🎖️[Easy] How to install, configure and test a 2 Node Mariadb 10.6 Galera Cluster on Ubuntu 22.04

🎖️[Easy] How to install, configure and test a 2 Node Mariadb 10.6 Galera Cluster on Ubuntu 22.04

Welcome to this tutorial on how to install, configure, and test a 2-node MariaDB Galera Cluster on Ubuntu 22.04. In this video, we’ll walk you through the process of setting up a highly available database cluster using the Galera replication technology.

We’ll start by installing and configuring the necessary software packages, including MariaDB and the Galera plugin. Then, we’ll create two nodes and configure them to communicate with each other over the network. We’ll also cover how to configure the cluster to handle failover scenarios.

Once the cluster is up and running, we’ll demonstrate how to test its functionality by performing various database operations, such as creating tables and inserting data. We’ll also show you how to monitor the cluster and troubleshoot any issues that may arise.

By the end of this tutorial, you’ll have a solid understanding of how to deploy a 2-node MariaDB Galera Cluster on Ubuntu 22.04 and ensure high availability for your database. So, let’s get started!

Install MariaDB Galera Cluster on Ubuntu 22.04.2 LTS with ProxySQL

Adapt and then Copy & Past
#Update servers
sudo su
apt update && apt -y upgrade
vi /etc/hosts
192.168.1.64 batman
192.168.1.65 superman

#nstall MariaDB on all nodes
apt update
sudo apt -y install mariadb-server mariadb-client
sudo mysql_secure_installation

mysql -u root -p

#Configure Galera Node 1 (batman) – Create config file
vi /etc/mysql/conf.d/galera.cnf
============================================
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so

# Galera Cluster Configuration
wsrep_cluster_name=”test_cluster”
wsrep_cluster_address=”gcomm://batman,superman”

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address=”192.168.1.64″
wsrep_node_name=”batman_node”
============================================

# Configure Galera Node 2 (superman)
vi /etc/mysql/conf.d/galera.cnf
============================================
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so

# Galera Cluster Configuration
wsrep_cluster_name=”test_cluster”
wsrep_cluster_address=”gcomm://batman,superman”

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address=”192.168.1.65″
wsrep_node_name=”superman”
============================================

#STOP MariaDB on both nodes
sudo systemctl stop mysql

#Startup first node (batman)
galera_new_cluster

#Check node status (1)
mysql -u root -p -e “SHOW STATUS LIKE ‘wsrep_cluster_size'”

#Bring Up the Second Node

systemctl start mariadb

#Check node status (2)
mysql -u root -p -e “SHOW STATUS LIKE ‘wsrep_cluster_size'”

#Write to the First Node
mysql -u root -p -e ‘CREATE DATABASE playground;
CREATE TABLE playground.equipment ( id INT NOT NULL AUTO_INCREMENT, type VARCHAR(50), quant INT, color VARCHAR(25), PRIMARY KEY(id));
INSERT INTO playground.equipment (type, quant, color) VALUES (“slide”, 2, “blue”);’

#Read and Write on the Second Node
mysql -u root -p -e ‘SELECT * FROM playground.equipment;’
mysql -u root -p -e ‘INSERT INTO playground.equipment (type, quant, color) VALUES (“swing”, 10, “yellow”);’

#Read on the First Node
mysql -u root -p -e ‘SELECT * FROM playground.equipment;’