This guide details the process of setting up a MariaDB Galera Cluster, where all nodes act as master servers, providing high availability and fault tolerance for your database environment.
Install MariaDB and Galera packages on all nodes:
dnf -y install mariadb-server-galera
Configure Firewall:
firewall-cmd --add-service=mysql
firewall-cmd --add-port={3306/tcp,4567/tcp,4568/tcp,4444/tcp} --permanent
firewall-cmd --reload
Galera Cluster Configuration:
/etc/my.cnf.d/galera.cnf with the following settings:[mysqld]
wsrep_on=1
wsrep_cluster_name="Galera_Cluster"
wsrep_cluster_address="gcomm://"
wsrep_node_address="10.0.0.31"
galera_new_cluster
systemctl enable mariadb
wsrep_cluster_address to include all node addresses after the first node starts successfully:wsrep_cluster_address="gcomm://10.0.0.31,10.0.0.51"
Run Initial Security Setup:
mysql_secure_installation
wsrep_node_address is set to each node's own IP address:[mysqld]
wsrep_on=1
wsrep_cluster_name="Galera_Cluster"
wsrep_cluster_address="gcomm://10.0.0.31,10.0.0.51"
wsrep_node_address="10.0.0.51"
systemctl enable --now mariadb
Check Cluster Synchronization:
SHOW STATUS LIKE 'wsrep_%';
wsrep_local_state_comment is Synced. This indicates that the node is properly synchronized with the cluster.Test Cluster Functionality: