环境
至少需要三个节点,不能安装mariadb-server
MySQL复制:
~]# yum install MariaDB-Galera-server
~]# vim /etc/my.cnf.d/server.cnf
[galera]
wsrep_provider = /usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address = "gcomm://172.16.0.7,172.16.0.17,172.16.0.27"
binlog_format = row
default_storage_engine = InnoDB
innodb_autoinc_lock_mode = 2
bind-address = 0.0.0.0
# 下面配置可选项
wsrep_cluster_name = 'mycluster' # 默认 my_wsrep_cluster
wsrep_node_name = 'node1'
wsrep_node_address = '172.16.0.7'
首次启动时,需要初始化集群,在其中一个节点上执行命令:
/etc/init.d/mysql start --wsrep-new-cluster
而后正常启动其它节点:
service mysql start
查看集群中相关系统变量和状态变量:
SHOW VARIABLES LIKE 'wsrep_%';
SHOW STATUS LIKE 'wsrep_%';
SHOW STATUS LIKE 'wsrep_cluster_size';