How to setup three nodes MariaDB Galera Cluster on Single server with MySQL sandbox

For the production environment, it’s recommended that we should use separate server for each Galera Cluster node but sometimes, for the testing purpose we have to setup it on one server with different ports. Here are the steps for how to do that with CentOS 6.8, MariaDB Galera Cluster 10.1.21 and MySQL Sandbox

  • Download MariaDB 10.1.21 from this location

https://downloads.mariadb.org/mariadb/10.1.21/

  • If you want to use sst method = xtrabackup then install it with yum repo    

https://www.percona.com/doc/percona-xtrabackup/2.3/installation/yum_repo.html

  • While installing xtrabackup you might get error like this if there is a fresh CentOS server,
If you see below dependencies while installing extra backup
--> Processing Dependency: perl(DBD::mysql) for package: percona-xtrabackup-2.3.7-2.el6.x86_64
--> Processing Dependency: libev.so.4()(64bit) for package: percona-xtrabackup-2.3.7-2.el6.x86_64
install perl-DBD-mysql and libev with

sudo yum install perl-DBD-mysql
get latest EPEL repo from here: https://fedoraproject.org/wiki/EPEL

sudo yum install libev then install Percona-xtrabackup

sudo yum install percona-xtrabackup

  • Now, install MariaDB three nodes cluster with MySQL sandbox,                            
[root@centos68 ~]# make_multiple_sandbox --how_many_nodes=3 mariadb-10.1.21-linux-x86_64.tar.gz
  • By default sandbox will start all three nodes so stop all three nodes and change these two things on all nodes i.e
#bind-address       = 127.0.0.1  -- comment this one
binlog_format=ROW -- set this to ROW if STATEMENT/MIXED
  • set below parameters in my.cnf and Bootstrap node1    
# Galera Cluster Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=1G"
wsrep_cluster_name="my_galera_cluster"
wsrep_cluster_address="gcomm://127.0.0.1:5030,127.0.0.1:6030"
wsrep_node_incoming_address="127.0.0.1"
wsrep_sst_method=rsync
wsrep_provider_options="gmcast.listen_addr=tcp://127.0.0.1:4030"
wsrep_sst_auth=root:msandbox
wsrep_node_name="node1"
[nilnandan@centos68 ~]# /home/nilnandan/Downloads/10.1.21/bin/mysqld 
--defaults-file=/home/nilnandan/sandboxes/multi_msb_mariadb-10_1_21/node1/my.sandbox.cnf 
--wsrep-new-cluster &
  • If it failed with this error, 
2017-03-07 17:37:30 139976434280288 [ERROR] WSREP: wsrep_load(): dlopen(): libssl.so.6: cannot open shared object file: No such file or directory

create symlinks for libssl.so.6 and libcrypto.sp.6

[root@centos68 ~]# cd /usr/lib64
[root@centos68 lib64]# ln -s libcrypto.so.1.0.1e libcrypto.so.6
[root@centos68 lib64]# ln -s libssl.so.1.0.1e libssl.so.6
  • If first node started successfully then,
MariaDB [(none)]> show global status like 'wsrep_cluster_size%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 1 |
+--------------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> show global variables like 'wsrep_on%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wsrep_on | ON |
+---------------+-------+
1 row in set (0.00 sec)
  • Now set parameters for node2 and bring it up.
binlog_format="ROW"
# Galera Cluster Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=1G"
wsrep_cluster_name="my_galera_cluster"
wsrep_cluster_address="gcomm://127.0.0.1:4030,127.0.0.1:6030"
wsrep_node_incoming_address="127.0.0.1"
wsrep_provider_options="gmcast.listen_addr=tcp://127.0.0.1:5030"
wsrep_sst_method=rsync
wsrep_sst_auth=root:msandbox
wsrep_node_name="node2"
[nilnandan@centos68 ~/sandboxes/multi_msb_mariadb-10_1_21/node2$ ./start
........ sandbox server started
[nilnandan@centos68 ~/sandboxes/multi_msb_mariadb-10_1_21/node2$
  • check again wsrep_cluster_size, 
MariaDB [(none)]> show global status like 'wsrep_cluster_size%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 2 |
+--------------------+-------+
1 row in set (0.00 sec)
  • second node added now set parameters for node3 and bring it up.
binlog_format="ROW"
# Galera Cluster Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=1G"
wsrep_cluster_name="my_galera_cluster"
wsrep_cluster_address="gcomm://127.0.0.1:4030,127.0.0.1:5030"
wsrep_node_incoming_address="127.0.0.1"
wsrep_provider_options="gmcast.listen_addr=tcp://127.0.0.1:6030"
wsrep_sst_method=rsync
wsrep_sst_auth=root:msandbox
wsrep_node_name="node3"
[nilnandan@centos68 ~/sandboxes/multi_msb_mariadb-10_1_21/node3$ ./start
........ sandbox server started
[nilnandan@centos68 ~/sandboxes/multi_msb_mariadb-10_1_21/node3$
  • Check wsrep_cluster_size
MariaDB [(none)]> show global status like 'wsrep_cluster_size%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+
1 row in set (0.00 sec)

So three node cluster is ready to test.

Picture credit: https://www.xyxon.co.jp/lineup/mariadb/cluster/index.html

Leave a Reply

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