欢迎关注MySQL 8.0必知必会系列课程。
MySQL8.0必知必会-自动化部署 https://edu.51cto.com/course/16368.html
MySQL8.0必知必会之参数标准化配置 https://edu.51cto.com/course/16358.html
1 环境准备
1.1 关闭firewall
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
1.1.2 关闭selinux
vi /etc/selinux/config
SELINUX=disabled
1.3 卸载已安装的mysql和mariadb
yum list|grep mysql
yum list|grep mariadb
1.4 安装pxc yum源
wget https://www.percona.com/redir/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
rpm -ivh percona-release-0.1-6.noarch.rpm
yum clean all
yum makecache
1.5 安装pxc软件
yum install -y Percona-Server-server-57
或者把包下载后直接安装
yum install -y Percona-XtraDB-Cluster-shared-57-5.7.22-29.26.1.el7.x86_64.rpm
yum install -y Percona-XtraDB-Cluster-client-57-5.7.22-29.26.1.el7.x86_64.rpm
yum install -y Percona-XtraDB-Cluster-server-57-5.7.22-29.26.1.el7.x86_64.rpm
1.6 源码安装需要的rpm包
yum install -y git scons gcc gcc-c++ openssl check cmake bison \
boost-devel asio-devel libaio-devel ncurses-devel readline-devel pam-devel \
socat
2 三台机器搭建PXC
192.168.10.159
192.168.10.160
192.168.10.161
2.1 第一节点
2.1.1参数
/etc/my.cnf
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so wsrep_cluster_name=pxc wsrep_cluster_address='gcomm://192.168.10.159,192.168.10.160,192.168.10.161' wsrep_node_name=pxc1 wsrep_node_address=192.168.10.159 wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth=sstuser:passw0rd pxc_strict_mode=ENFORCING binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 |
2.1.2第一个节点启动
systemctl start mysql@bootstrap.service
2.1.3创建用户
在error log中找到root@localhost的temporary password
grep temp mysql_error.log
CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'passw0rd'; GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO'sstuser'@'localhost'; FLUSH PRIVILEGES; |
2.2 第二节点
server_id需要修改
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so wsrep_cluster_name=pxc wsrep_cluster_address='gcomm://192.168.10.159,192.168.10.160,192.168.10.161' wsrep_node_name=pxc2 wsrep_node_address=192.168.10.160 wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth=sstuser:passw0rd pxc_strict_mode=ENFORCING binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 |
启动:systemctl start mysql
2.3 第三节点
server_id需要修改
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so wsrep_cluster_name=pxc wsrep_cluster_address='gcomm://192.168.10.159,192.168.10.160,192.168.10.161' wsrep_node_name=pxc3 wsrep_node_address=192.168.10.161 wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth=sstuser:passw0rd pxc_strict_mode=ENFORCING binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 |
启动:systemctl start mysql
转载于:https://blog.51cto.com/14136767/2334518