Features:
Synchronous replication
Active-active multi-master topology
Read and write to any cluster node
Automatic membership control, failed nodes drop from the cluster
Automatic node joining
True parallel replication, on row level
Direct client connections, native MySQL look & feel
Benefits:
The above features yield several benefits for a DBMS clustering solution, including:
No slave lag
No lost transactions
Both read and write scalability
Smaller client latencies
For this setup, we have 2 nodes.(ie 192.168.1.11,192.168.1.12.) MariaDB will first setup in (.11) and start in bootstrap mode. After (.11) has started, (.12) will setup next. Once the MariaDB service on (.12) started, Galera process will sync database data and transactions from (.11) to (.12), and after in sync, MariaDB in (.12) will turn on. Both servers will be multi masters and in sync constantly.
To begin with the setup, for simplicity, we will switch off selinux and firewall.
[root@centos7-11 ~]#systemctl stop firewalld [root@centos7-11 ~]#systemctl disable firewalld [root@centos7-11 ~]#vi /etc/selinux/config
disabled
[root@centos7-11 ~]#rebootWe will add a repository from MariaDB.
[root@centos7-11 ~]# vi /etc/yum.repos.d/mariadb.repo
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.0/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1Install the package using YUM.
[root@centos7-11 ~]# yum clean all [root@centos7-11 ~]# yum install MariaDB-Galera-serverSetup MariaDB.(At this point,the service is still call mysql.)
[root@centos7-11 ~]# service mysql start [root@centos7-11 ~]# mysql_secure_installationStop the mysql service to adjust the MariaDB config file.
[root@centos7-11 ~]# service mysql stop [root@centos7-11 ~]# vi /etc/my.cnf
!includedir /etc/my.cnf.dAdd replication parameters to server.cnf
[root@centos7-11 ~]# vi /etc/my.cnf.d/server.cnf
[galera] # Mandatory settings wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address=gcomm:// binlog_format=row default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 bind-address=192.168.1.11 # # Optional setting #wsrep_slave_threads=1 #innodb_flush_log_at_trx_commit=0We can start the MariaDB on first node.(.11)
[root@centos7-11 ~]# service mysql startBy now, this node has setup to be the first master database. We shell proceed to setup the second master database.
Similarly, we will switch off selinux and firewall.
[root@centos7-12 ~]#systemctl stop firewalld [root@centos7-12 ~]systemctl disable firewalld [root@centos7-12 ~]vi /etc/selinux/config
disabled
[root@centos7-12 ~]rebootWe will add a repository from MariaDB.
[root@centos7-12 ~]# vi /etc/yum.repos.d/mariadb.repo
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.0/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1Install the package using YUM.
[root@centos7-12 ~]# yum clean all [root@centos7-12 ~]# yum install MariaDB-Galera-serverAt this point, we just need to configure the MariaDB config files
[root@centos7-12 ~]# vi /etc/my.cnf
!includedir /etc/my.cnf.dAdd replication parameters to server.cnf
[root@centos7-12 ~]# vi /etc/my.cnf.d/server.cnf
[galera] # Mandatory settings wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address=gcomm://192.168.1.11 binlog_format=row default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 bind-address=192.168.1.12 # # Optional setting #wsrep_slave_threads=1 #innodb_flush_log_at_trx_commit=0We can start the MariaDB on second node.(.12)
[root@centos7-12 ~]# service mysql startAnd thats it, 2 node multi masters MariaDB clusters.