搭建同步复制的数据库集群,使用MariaDB Galera 且至少需要预先搭建三台Linux服务器。
其中在上一篇博客中有一步是需要修改wsrep.cnf这个文件中的三个参数,其中
wsrep_cluster_address="gcomm://192.168.131.145
其中那个IP地址表示的是相对于本台Linux所表示的节点的上一个服务器节点的IP地址。如果本台Linux服务器是第一个节点,那么所填写的就是本台Linux的IP
例如我搭建了三台Linux:Ip分别为
其中第一节点的此处填写的是本机IP,第二节点填写的是第一节点的IP,第三节点填写的是第二节点的IP以此类推。
wsrep.cnf文件内容如下所示(加粗为修改内容)
[root@localhost ~]# vi /etc/my.cnf.d/wsrep.cnf
# This file contains wsrep-related mysqld options. It should be included
# in the main MySQL configuration file.
#
# Options that need to be customized:
# - wsrep_provider
# - wsrep_cluster_address
# - wsrep_sst_auth
# The rest of defaults should work out of the box.
##
## mysqld options _MANDATORY_ for correct opration of the cluster
##
[mysqld]
# (This must be substituted by wsrep_format)
binlog_format=ROW
# Currently only InnoDB storage engine is supported
default-storage-engine=innodb
# to avoid issues with 'bulk mode inserts' using autoinc
innodb_autoinc_lock_mode=2
# Override bind-address
# In some systems bind-address defaults to 127.0.0.1, and with mysqldump SST
# it will have (most likely) disastrous consequences on donor node
bind-address=0.0.0.0
##
## WSREP options
##
# Enable wsrep
wsrep_on=1
# Full path to wsrep provider library or 'none'
wsrep_provider=/usr/lib64/galera/libgalera_smm.so // 修改部分
# Provider specific configuration options
#wsrep_provider_options=
# Logical cluster name. Should be the same for all nodes.
wsrep_cluster_name="my_wsrep_cluster"
# Group communication system handle
wsrep_cluster_address="gcomm://192.168.131.145"// 修改部分
/wsrep_sst_auth
## WSREP State Transfer options
##
# State Snapshot Transfer method
wsrep_sst_method=rsync
# Address which donor should send State Snapshot to.
# Should be the address of THIS node. DON'T SET IT TO DONOR ADDRESS!!!
# (SST method dependent. Defaults to the first IP of the first interface)
#wsrep_sst_receive_address=
# SST authentication string. This will be used to send SST to joining nodes.
# Depends on SST method. For mysqldump method it is root:<root password>
wsrep_sst_auth=sst:123456