centos7安装pxc集群

centos7安装pxc集群

1,卸载maridb

yum -y remove mari*

2,开放端口

firewall-cmd --zone=public --add-port=3006/tcp --permanent
##请求全量同步ssT
firewall-cmd --zone=public --add-port=4444/tcp --permanent
##节点之间通信的端口
firewall-cmd --zone=public --add-port=4567/tcp --permanent
##请求增量同步的端口 lsT
firewall-cmd --zone=public --add-port=4568/tcp --permanent

3,关闭selinux

vi /etc/selinux/config
##打开后设置SELINUX=disabled

4,安装pxc

百度网盘pxc

提取密码:f6mx

因为在线安装实在太慢,我把rpm包下载到本地了
这里说明一下,Percona-XtraDB-Cluster依赖Percona-XtraBackup,所以我把对应版本下下来了不然在线下载依赖真的太慢了,会导致下载失败

 ##安装yum源
 yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
 ##定位到pxc57的仓库
  percona-release setup pxc57
 #解压
 tar vxf Percona-XtraBackup-2.4.14-ref675d4-el7-x86_64-bundle.tar
 tar vxf Percona-XtraDB-Cluster-5.7.25-31.35-r463-el7-x86_64-bundle.tar
 ##安装rpm包用yum localinstall 命令率先从本地安装,并根据本地rpm包会在线寻找未安装的依赖(pxc官网下载的安装包会依赖其他包)
 yum localinstall *.rpm
 ##启动服务
 service mysql start

5,修改root账号密码

grep 'temporary password' /var/log/mysqld.log
##root登陆
mysql -uroot -p

如果临时密码不行,改变mysql配置文件,省略密码登陆方式

修改my.cnf 添加skip-grant-tables,然后root登陆

update mysql.user set authentication_string=PASSWORD(‘201104abcD!’) where User=‘root’;

ALTER USER 'root'@'localhost' IDENTIFIED BY '201104abcD!';
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '201104abcD!' WITH GRANT OPTION;
flush privileges;
##创建pxc的sst账户用户同步
CREATE USER 'sstuser'@'localhost' IDENTIFIED BY '201104abcD!';
 GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
 FLUSH PRIVILEGES;

6,同样方式安装其余两台pxc节点,并修改三个节点的配置文件

cd /etc/percona-xtradb-cluster.conf.d/
#############修改mysql.cnf的serverid值,使得各个节点不一样#######
vim mysql.cnf
#################修改wsrep.cnf############
#各个节点ip
wsrep_node_address=192.168.123.151
#cluster 节点ip
wsrep_cluster_address=gcomm://192.168.123.150,192.168.123.151,192.168.123.152
#节点名字,三个节点不一样
wsrep_node_name=pxc-cluster-node-1
##sst账户
wsrep_sst_auth="sstuser:201104abcD!"

6,主节点启动方式

##停掉之前的所有mysql服务,以集群的方式启动
service  [email protected]  start

7,后续节点启动方式

service mysql start

8,遇见问题

启动第二个节点时遇到sst连接失败的问题

	2019-05-28T13:18:32.315429Z WSREP_SST: [INFO] Proceeding with SST.........
	2019-05-28T13:18:32.346480Z WSREP_SST: [INFO] ............Waiting for SST streaming to complete!
2019-05-28T13:18:32.803936Z 0 [Note] WSREP: (15b06b02, 'tcp://0.0.0.0:4567') turning message relay requesting off
	2019-05-28T13:18:42.495136Z WSREP_SST: [ERROR] ******************* FATAL ERROR ********************** 
	2019-05-28T13:18:42.496120Z WSREP_SST: [ERROR] xtrabackup_checkpoints missing. xtrabackup/SST failed on DONOR. Check DONOR log
	2019-05-28T13:18:42.497082Z WSREP_SST: [ERROR] ****************************************************** 
	2019-05-28T13:18:42.498333Z WSREP_SST: [ERROR] Cleanup after exit with status:2
2019-05-28T13:18:42.509149Z 0 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.123.151' --datadir '/var/lib/mysql/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --parent '16636' --mysqld-version '5.7.25-28-57'   '' : 2 (No such file or directory)
2019-05-28T13:18:42.509214Z 0 [ERROR] WSREP: Failed to read uuid:seqno from joiner script.
2019-05-28T13:18:42.509227Z 0 [ERROR] WSREP: SST script aborted with error 2 (No such file or directory)
2019-05-28T13:18:42.509263Z 0 [ERROR] WSREP: SST failed: 2 (No such file or directory)
2019-05-28T13:18:42.509272Z 0 [ERROR] Aborting

解决办法:

将wsrep.cnf 配置文件的wsrep_sst_method改为rsync,成功启动集群后停止集群,然后改回xtrabackup-v2,再启动集群节点。发笑错误消失。原因有待完善。

9,静止pxc的开机启动

chkconfig mysql off

你可能感兴趣的:(linux)