文章借鉴:https://www.cnblogs.com/zejin2008/p/5475285.html
yum安装:
wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/Percona-XtraDB-Cluster-5.7.24-31.33/binary/redhat/6/x86_64/Percona-XtraDB-Cluster-5.7.24-31.33-r443-el6-x86_64-bundle.tar
二进制安装:
• ssl100: for Debian prior to 9 and Ubuntu prior to 14.04 versions
• ssl101: for CentOS 6 and CentOS 7
• ssl102: for Debian 9 and Ubuntu versions starting from 14.04
wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/Percona-XtraDB-Cluster-5.7.24-31.33/binary/tarball/Percona-XtraDB-Cluster-5.7.24-rel26-31.33.1.Linux.x86_64.ssl100.tar.gz
• 3306 is used for MySQL client connections and SST (State Snapshot Transfer) via mysqldump.
• 4444 is used for SST via rsync and Percona XtraBackup.
• 4567 is used for write-set replication traffic (over TCP) and multicast replication (over TCP and UDP).
• 4568 is used for IST (Incremental State Transfer).
测试环境部署:192.168.1.221,192.168.1.222,192.168.1.223
环境准备
全部节点如下配置:
mkdir -p /data/mysql/3307/{binlog,conf,data,log,pid,socket,tmp}
chown -R mysql.mysql /data/mysql
mv Percona-XtraDB-Cluster-5.7.24-rel26-31.33.1.Linux.x86_64.ssl101 /usr/local/Percona-XtraDB-Cluster-5.7.24
每个节点都需要按照xtrabackup工具,否则后面两个节点无法启动
wget https://repo.percona.com/yum/percona-release-1.0-7.noarch.rpm
rpm -ivh percona-release-1.0-7.noarch.rpm
yum -y install percona-xtrabackup-24.x86_64
如报错: Requires: libev.so.4()(64bit)
则:wget ftp://rpmfind.net/linux/atrpms/el6-x86_64/atrpms/stable/libev-4.04-2.el6.x86_64.rpm
rpm -ivh libev-4.04-2.el6.x86_64.rpm
同时版本要匹配,percona-xtrabackup-80-8.0.5只使用percona 8.0
每个节点安装socat,socat版本尽量在1.7.3以上
yum install socat
或者
wget http://www.dest-unreach.org/socat/download/socat-1.7.3.2.tar.gz
./configure && make && make install
192.168.1.221修改配置文件,增加如下:
wsrep_provider=/usr/local/Percona-XtraDB-Cluster-5.7.24/lib/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
wsrep_cluster_address=gcomm://192.168.1.221,192.168.1.222,192.168.1.223
wsrep_node_name=pxc1
wsrep_node_address=192.168.1.221
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
192.168.1.222按192.168.1.221增加的修改配置文件如下:
.......
wsrep_node_name=pxc2
wsrep_node_address=192.168.1.222
........
192.168.1.222按192.168.1.221增加的修改配置文件如下:
........
wsrep_node_name=pxc3
wsrep_node_address=192.168.1.223
........
集群第一个节点:221
初始化:
/usr/local/Percona-XtraDB-Cluster-5.7.24/bin/mysqld --defaults-file=/data/mysql/3307/conf/my.cnf --user=mysql --initialize
启动,集群中第一个节点启动要加选项 --wsrep-new-cluster
/usr/local/Percona-XtraDB-Cluster-5.7.24/bin/mysqld_safe --defaults-file=/data/mysql/3307/conf/my.cnf --user=mysql --wsrep-new-cluster &
授权
CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'passw0rd';
GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
节点222,223:
/usr/local/Percona-XtraDB-Cluster-5.7.24/bin/mysqld --defaults-file=/data/mysql/3307/conf/my.cnf --user=mysql --initialize
/usr/local/Percona-XtraDB-Cluster-5.7.24/bin/mysqld_safe --defaults-file=/data/mysql/3307/conf/my.cnf --user=mysql &
网站标题:MySQLPXC部署实践
文章位置:
http://bjjierui.cn/article/gsgjdg.html