MariaDB Galera Cluster on CentOS 7

vi /etc/selinux/config

Change SELINUX=enforcing to SELINUX=disabled

firewall-cmd --zone=public --add-port=3306/tcp --permanent 
firewall-cmd --zone=public --add-port=4567/tcp --permanent
firewall-cmd --zone=public --add-port=4568/tcp --permanent 
firewall-cmd --zone=public --add-port=4444/tcp --permanent
firewall-cmd --zone=public --add-port=4567/udp --permanent
firewall-cmd --reload

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash

yum makecache fast
yum -y install epel-release
yum -y install mariadb-server mariadb-client galera rsync mariadb-server

 systemctl start mariadb

mysql_secure_installation

systemctl stop mariadb

vi /etc/hosts

#mysql clustering

192.168.5.50 db-node0

192.168.5.52 db-node1

192.168.8.52 db-node2

vi /etc/my.cnf.d/server.cnf
[galera]
# Mandatory settings 
wsrep_on=ON 
wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address=gcomm://192.168.5.50,192.168.5.52,192.168.8.52
binlog_format=row 
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2 
wsrep_cluster_name="mysql-cluster"
# Allow server to accept connections on all interfaces.
bind-address=0.0.0.0
# this server ip, change for each server
wsrep_node_address="192.168.5.50"
# this server name, change for each server
wsrep_node_name="db-node0"
wsrep_sst_method=rsync 

Start service:

Start Node 1 with master node:

galera_new_cluster

Start Node 2 and Node 3:

systemctl start mariadb

[email protected] ~]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 10

Server version: 10.3.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show global status like ‘wsrep_cluster_size’;

Enable mariadb on all server

Systemctl enable mariadb

Leave a Reply

Your email address will not be published. Required fields are marked *