1. yum -y groupinstall Base Compatibility libraries Debugging Tools Dial-up Networking suppport Hardware monitoring utilities Performance Tools Development tools
2. 关闭当前服务器上的mysql,并且把/usr/local 下的mysql文件夹挪走
3. wget http://oss.jiugell.com/toolBox/63a9f0ea7bb98050796b649e85481845/software/pxc/Percona-XtraDB-Cluster-5.7.30-rel33-43.1.Linux.x86_64.ssl102.tar.gz
4. tar -zxvf Percona-XtraDB-Cluster-5.7.30-rel33-43.1.Linux.x86_64.ssl102.tar.gz -C /opt
5. ln -s /opt/Percona-XtraDB-Cluster-5.7.30-rel33-43.1.Linux.x86_64.ssl102/ /usr/local/mysql
6. vim /etc/my.cnf
7. 到最后一行 换行填写
8. ###PXC配置
wsrep_node_name=pxc1
wsrep_node_address=10.255.40.89:4567
wsrep_provider=/usr/local/mysql/Percona-XtraDB-Cluster-5.7.30-rel33-43.1.Linux.x86_64.ssl102/lib/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
wsrep_cluster_address=gcomm://10.255.40.89:4567,10.255.40.83:4567
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:passw0rd
pxc_strict_mode=ENFORCING
9. 配置完成后 安装PX
10. wget http://oss.jiugell.com/toolBox/63a9f0ea7bb98050796b649e85481845/software/pxc/percona-xtrabackup-24-2.4.20-1.el7.x86_64.rpm
11. yum -y install percona-xtrabackup-24-2.4.20-1.el7.x86_64.rpm
12. yum -y install qpress socat
配置mysql
14. bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure
15. cd /usr/local
16. chmod -R 0777 mysql
17. cd mysql
18. bin/mysqld_safe --defaults-file=/etc/my.cnf --wsrep-new-cluster &
19. bin/mysql -uroot
20. set password='passw0rd';
21. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'passw0rd' WITH GRANT OPTION;
22. CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'passw0rd';
23. GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
24. FLUSH PRIVILEGES;
25. 其他节点启动 mysqld_safe --defaults-file=/etc/my.cnf &
26. show status like 'wsrep%';
下面是my.cnf
[client]
socket = /usr/local/mysql/data/mysql.sock
[mysqld]
####: mysqld基本设置
socket = /usr/local/mysql/data/mysql.sock
user =mysql # mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
character_set_server =utf8 # latin1
log_timestamps =system # utc
skip_name_resolve =1 # 0
lower_case_table_names =1 # 0
####: pxc必须满足的
server-id =72 # 0 #注意三台服务器的设置不同
binlog_format =row # row
default_storage_engine =InnoDB # InnoDB
innodb_autoinc_lock_mode =2 # 1
#### pxc配置
wsrep_node_name=pxc2 #注意三台服务器的设置不同。可以不配置,不配置时默认取hostname
wsrep_node_address=10.255.40.83:4567 #注意三台服务器的设置不同。可以不加端口,默认就是4567的pxc通讯端口,请注意不是mysql的3306监听端口!
wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
wsrep_cluster_address=gcomm://10.255.40.89:4567,10.255.40.83:4567
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:passw0rd
pxc_strict_mode=ENFORCING