标签:ble init member nod row log check lib64 key
环境:192.168.205.37: as member of galera-server
192.168.205.47: as member of galera-server
192.168.205.57: as member of galera-server
OS: centos 7 1810 with mini install
mariadb-server 5.5.64
集成了Galera插件的MySQL集群,是一种新型的,数据不共享的,高度冗余的高可用方案,目前Galera Cluster有两个版本,分别是Percona Xtradb Cluster及MariaDB Cluster,Galera本身是具有多主特性的,即采用multi-master的集群架构,是一个既稳健,又在数据一致性、完整性及高性能方面有出色表现的高可用解决方案。
Galera要求至少三个节点组成集群,与普通的主从架构不同,它们都可以作为主节点,三个节点是对等的,称为multi-master架构,当有客户端要写入或者读取数据时,连接哪个实例都是一样的,读到的数据是相同的,写入某一个节点之后,集群自己会将新数据同步到其它节点上面,这种架构不共享任何数据,是一种高冗余架构。
[root@centos7 ~]#cat > /etc/yum.repos.d/mysql.repo <<EOF
> [mysql]
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-5.5.64/yum/centos7-amd64/
> gpgcheck=0
> EOF
[root@centos7 ~]#yum install MariaDB-Galera-server
[root@centos7 ~]#vi /etc/my.cnf.d/server.cnf
[galera]
wsrep_provider = /usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.205.37,192.168.205
.47,192.168.205.57"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
wsrep_cluster_name = ‘testcluster‘
[root@centos7 ~]#/etc/init.d/mysql start --wsrep-new-cluster
Starting MariaDB.190813 08:55:40 mysqld_safe Logging to ‘/var/lib/mysql/centos7.localdomain.err‘.
190813 08:55:40 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
... SUCCESS!
[root@centos7 ~]#service mysql start
[root@centos7 ~]#mysql < hellodb_innodb.sql
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hellodb |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
SHOW VARIABLES LIKE ‘wsrep_%‘;
SHOW STATUS LIKE ‘wsrep_%‘;
SHOW STATUS LIKE ‘wsrep_cluster_size‘;
MariaDB [hellodb]> create table t1(id int);
Query OK, 0 rows affected (0.01 sec)
MariaDB [hellodb]> create table t1(id int);
ERROR 1050 (42S01): Table ‘t1‘ already exists
MariaDB [hellodb]> create table t1(id int);
ERROR 1050 (42S01): Table ‘t1‘ already exists
测试一下存储过程,会比一主一从慢很多,所以会牺牲一些性能问题,一般一主一从虚拟机插入10万条大概要15秒,但本实验用了分多钟。
MariaDB [hellodb]> create table testlog (id int auto_increment primary key,name char(10),age int default 20);
Query OK, 0 rows affected (0.02 sec)
MariaDB [hellodb]>
MariaDB [hellodb]> delimiter $$
MariaDB [hellodb]>
MariaDB [hellodb]> create procedure sp_testlog()
-> begin
-> declare i int;
-> set i = 1;
-> while i <= 100000
-> do insert into testlog(name,age) values (concat(‘wang‘,i),i);
-> set i = i +1;
-> end while;
-> end$$
Query OK, 0 rows affected (0.01 sec)
MariaDB [hellodb]>
MariaDB [hellodb]> delimiter ;
MariaDB [hellodb]> call sp_testlog;
Query OK, 1 row affected (3 min 5.20 sec)
我们以事务方式提交,发现快了很多
MariaDB [hellodb]> begin;
Query OK, 0 rows affected (0.00 sec)
MariaDB [hellodb]> call sp_testlog;
Query OK, 1 row affected (1.49 sec)
MariaDB [hellodb]> commit;
Query OK, 0 rows affected (0.42 sec)
标签:ble init member nod row log check lib64 key
原文地址:https://blog.51cto.com/127601/2429027