Install the MARIADB version of the package with the Galera cluster feature first:
Official Document: https://mariadb.com/kb/en/mariadb/getting-started-with-mariadb-galera-cluster/
The replication implemented by Galera cluster differs from the traditional way of replicating MySQL, where traditional replication is done by reading the transactions in the binary log of MySQL and then reproducing the data locally, while Galera cluster does not. It replicates data directly from the underlying data to other nodes via the WSREP protocol.
The experiment requires at least 3 MySQL servers, this time using the official Yum Source:
[MARIADB]
Name = MariaDB
BaseURL = Http://yum.mariadb.org/5.5/centos7-amd64
Gpgkey=https://yum.mariadb.org/rpm-gpg-key-mariadb
Gpgcheck=1
Experimental environment: Physical machine Win7, virtual machine 3 sets of CENTOS7;
node1:192.168.255.2
node2:192.168.255.3
node3:192.168.255.4
Install Mariadb-galera-server on each node, respectively
]# yum-y Install Mariadb-galera-server
]# rpm-ql galera |grep ' Libgalera '
/usr/lib64/galera/libgalera_smm.so
Log this path, which is used when configuring Galera;
Configuration Node 1:
]# vim/etc/my.cnf.d/server.cnf
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/82/92/wKiom1da4HDBYMTQAAA4Dlw6eTc901.png "title=" 1.png " Width= "729" height= "176" border= "0" hspace= "0" vspace= "0" style= "width:729px;height:176px;" alt= " Wkiom1da4hdbymtqaaa4dlw6etc901.png "/>
Copy the configuration file to another two nodes:
]# scp/etc/my.cnf.d/server.cnf node2:/etc/my.cnf.d/
]# scp/etc/my.cnf.d/server.cnf node3:/etc/my.cnf.d/
Initialize the startup database: in which any node execution is possible;
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/82/90/wKioL1da4qHRy-71AAAOgkwbTwI924.png "title=" 2.png " alt= "Wkiol1da4qhry-71aaaogkwbtwi924.png"/>
Start MySQL normally on the node 2,3
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/82/90/wKioL1da4xWiiYCQAAAQl0IISI8718.png "title=" 3.png " Width= "705" height= "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:705px;height:40px; "alt=" Wkiol1da4xwiiycqaaaql0iisi8718.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/82/92/wKiom1da4kOx43VYAAAPPYRZhAY248.png "title=" 4.png " Width= "703" height= "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:703px;height:42px; "alt=" Wkiom1da4kox43vyaaappyrzhay248.png "/>
The above galera cluster configuration is complete, the following verifies each node replication;
On Node 1:
> CREATE DATABASE mydb;
On Node 2:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/82/92/wKiom1da4tjS_JDnAAAiZEvNlXI819.png "title=" 5.png " alt= "Wkiom1da4tjs_jdnaaaizevnlxi819.png"/>
has been copied to the MyDB library created in node 1;
> Use mydb;
> CREATE TABLE tb1 (id int,name char (10));
On Node 3:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/82/90/wKioL1da5FrTJLGIAAAto907RfY703.png "title=" 6.png " Width= "705" height= "232" border= "0" hspace= "0" vspace= "0" style= "width:705px;height:232px;" alt= " Wkiol1da5frtjlgiaaato907rfy703.png "/>
The above realizes the MySQL multi-master replication function of Galera cluster based on WSREP protocol;
MySQL builds a multi-master cluster with Galera cluster