Mariadb Galera Cluster
环境准备
- 修改主机名
- 配置主机名解析
- 关闭防火墙 & selinux
- 配置 yum 源
echo "10.35.172.77 node1
10.35.172.78 node2
10.35.172.79 node3" >> /etc/hosts
echo "[mariadb]
name=mariadb
baseurl=ftp://10.35.172.81/gpmall-repo
gpgcheck=0
enabled=1
[centos]
name=centos
baseurl=ftp://10.35.172.81/centos
gpgcheck=0
enabled=1" > /etc/yum.repos.d/ftp.repo
安装Mariadb Galera Cluster
# 安装 mariadb
yum install mariadb-server -y
# 初始化数据库
systemctl start mariadb
mysql_secure_installation
u
# 配置数据库文件
/etc/my.cnf.d/server.cnf
# 修改数据库密码
grant all privileges on *.* to root@'%' identified by '123456';
# 停止数据库
systemctl stop mariadb
# 启动数据库集群
node1
galera_new_cluster
node2 & node3
systemctl start mariadb
# 验证
node1
MariaDB [(none)]> show status like "wsrep_ready";
MariaDB [(none)]> show status like "wsrep_cluster_size";
MariaDB [(none)]> show status like "wsrep%";
MariaDB [(none)]> create database abc;
MariaDB [(none)]> show databases;
node2
MariaDB [(none)]> show databases;
node3
MariaDB [(none)]> show databases;
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://10.35.172.77,10.35.172.78,10.35.172.79"
wsrep_node_name=node1
wsrep_node_address=10.35.172.77
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=0
innodb_buffer_pool_size=120M
wsrep_sst_method=rsync
wsrep_causal_reads=ON
bind-address=10.35.172.77