Mariadb Galera Cluster configuration on centOS 8

We create mariadb galera cluster with two nodes, assume nodes ip for first machine 150.236.189.166 and second machine 150.236.189.124

Step 1: Install mariadb server on CentOS 8
# yum install mariadb-server mariadb

Set root password
$ mysql_secure_installation

Step 2: Firewall stop
# systemctl start firewalld
# systemctl enable firewalld
# vim /etc/selinux/config
SELINUX=disabled

@ Add same host into both machine
# vim /etc/hosts
150.236.189.166 n1
150.236.189.124 n2

Step 3: install galeria using yum
# yum install galera

Step 4: Galera Master node configuration
We need to add the following content to MariaDB configuration file in /etc/my.cnf.d/mariadb-server.cnf under [galera] section

[galera]
# Mandatory settings
wsrep_on=ON
wsrep-debug=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://150.236.189.166,150.236.189.124"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
# Allow server to accept connections on all interfaces.
bind-address=0.0.0.0
## Galera Cluster Configuration
wsrep_cluster_name="my_wsrep_cluster"
## Galera Synchronization Configuration
wsrep_sst_method=rsync
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# Host machine configuration
wsrep_node_address="150.236.189.166"
wsrep_node_name="n1"

Step 5: We are now ready to create the cluster. Keep in mind that do not run the cluster creation command on more than one node. execute below command
# galera_new_cluster

Step 6: Verify Galera Master Node
# mysql -uroot -p (connect mysql connection)
# SHOW STATUS LIKE 'wsrep_cluster_size';

Step 7: Adding Additional Nodes to Galera Cluster
Follow Step 4 to add the content of [galera] section of the nodes. Only change the value for node address and node name respectively:
wsrep_node_address="150.236.189.124"
wsrep_node_name="n2"

Step 8: restart mariadb server and check the cluster
# systemctl restart mariadb.service
# SHOW STATUS LIKE 'wsrep_cluster_size';
+--------------------+-------+
   | Variable_name | Value |
   +--------------------+-------+
   | wsrep_cluster_size | 2 |
   +--------------------+-------+


Post a Comment

0 Comments

3