Galera Clustergalera Cluster1, requires a dedicated download support Galera-cluster support MARIADB Branch 1.1
需要准备三个节点;
1.2 Configuring time Synchronization
[[email protected] ~]# ntpdate s2c.time.edu.cn[[email protected] ~]# ntpdate s2c.time.edu.cn[[email protected] ~]# ntpdate s2c.time.edu.cn配置yum源:[[email protected] galera_cluster]# vim /etc/yum.repos.d/galera.repo [galera]name=Galera Cluster from MariaDBbaseurl=http://10.201.106.1:8080/galera_cluster/enabled=1gpgcheck=0[[email protected] galera_cluster]# yum list | grep GaleMariaDB-Galera-server.x86_64 5.5.46-1.el7.centos galera MariaDB-Galera-test.x86_64 5.5.46-1.el7.centos
2, clear the previous mariadb
yum remove mariadb-serveryum remove mariadb
3, installation 3.1 installation Galera
[[email protected] galera_cluster]# yum install MariaDB-Galera-server[[email protected] galera_cluster]# yum install MariaDB-Galera-server[[email protected] galera_cluster]# yum install MariaDB-Galera-server
3.2 Viewing the installation build file
[[email protected] ~]# rpm -ql galera | grep -i smm.so/usr/lib64/galera/libgalera_smm.so
4, Configuration galera-server4.0
[[email protected] ~]# rpm -ql galera | grep -i smm.so/usr/lib64/galera/libgalera_smm.so
4.1 Configuration
[[email protected] ~]# vim /etc/my.cnf.d/server.cnf [galera]# Mandatory settingswsrep_provider=/usr/lib64/galera/libgalera_smm.sowsrep_cluster_address="gcomm://10.201.106.131,10.201.106.132,10.201.106.133"binlog_format=rowdefault_storage_engine=InnoDBinnodb_autoinc_lock_mode=2bind-address=0.0.0.0wsrep_cluster_name=‘mycluster‘## Optional setting#wsrep_slave_threads=1#innodb_flush_log_at_trx_commit=0
4.2 Copying files to a node 2,3
[[email protected] ~]# scp /etc/my.cnf.d/server.cnf master2:/etc/my.cnf.d/server.cnf 100% 1140 1.1KB/s 00:00 [[email protected] ~]# scp /etc/my.cnf.d/server.cnf master3:/etc/my.cnf.d/server.cnf 100% 1140 1.1KB/s 00:00
5. Start 5.1 init service
5.2 Test Creation
节点1MariaDB [(none)]> CREATE DATABASE mydb;节点3MariaDB [(none)]> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mydb |节点2MariaDB [mydb]> CREATE TABLE tb1(id int,name char(10));节点1:MariaDB [mydb]> DESC tb1;+-------+----------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+----------+------+-----+---------+-------+| id | int(11) | YES | | NULL | || name | char(10) | YES | | NULL | |+-------+----------+------+-----+---------+-------+
6, the demonstration simultaneously inserts the data 6.1
节点1MariaDB [mydb]> CREATE TABLE tb2(id int UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,name CHAR(30));MariaDB [mydb]> INSERT INTO tb2 (name) VALUES(‘hi‘),(‘hello‘);节点2MariaDB [mydb]> SELECT * FROM tb2;+----+-------+| id | name |+----+-------+| 1 | hi || 4 | hello |MariaDB [mydb]> INSERT INTO tb2(name) VALUES (‘to‘),(‘from‘);Query OK, 2 rows affected (0.02 sec)Records: 2 Duplicates: 0 Warnings: 0MariaDB [mydb]> SELECT * FROM tb2;+----+-------+| id | name |+----+-------+| 1 | hi || 4 | hello || 5 | to || 8 | from |+----+-------+插入ID:找一个全局惟一ID生成器,可以专门找一台服务器生成ID,不做其他事情。
Mariadb-galera Cluster Miscellaneous Notes