PXC
centos8下安装pxc-80
官方地址
https://www.percona.com/doc/percona-repo-config/index.html
https://www.percona.com/doc/percona-xtradb-cluster/LATEST/install/yum.html#yum
yum仓库配置
# 安装仓库管理器
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm -y
# 禁用mysql模组
yum module disable mysql -y
安装pxc
# 安装pxc
percona-release enable-only pxc-80 release
percona-release enable tools release
yum install percona-xtradb-cluster -y
初始化及配置
# 创建证书文件
mkdir -p /etc/mysql/certs/
mysql_ssl_rsa_setup -d /etc/mysql/certs/
# 将文件复制到集群所有节点的/etc/mysql/certs/目录,并设置所有者为mysql
scp /etc/mysql/certs/* 10.1.1.22:/etc/mysql/certs/
chown -R mysql:mysql /etc/mysql/
编辑/etc/my.cnf
# /etc/my.cnf
[mysqld]
ssl-ca = /etc/mysql/certs/ca.pem
ssl-cert = /etc/mysql/certs/server-cert.pem
ssl-key = /etc/mysql/certs/server-key.pem
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
skip-host-cache
binlog_format=ROW
default_storage_engine=InnoDB
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_autoinc_lock_mode=2
bind_address = 0.0.0.0
wsrep_slave_threads=2
wsrep_cluster_address=gcomm://10.1.1.20,10.1.1.21,10.1.1.22 # 集群地址
wsrep_provider=/usr/lib64/galera4/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
#wsrep_node_address=10.1.1.20 # 所在节点的ip地址,可以不配置
wsrep_sst_method=xtrabackup-v2
[client]
socket=/tmp/mysql.sock
ssl-ca = /etc/mysql/certs/ca.pem
ssl-cert = /etc/mysql/certs/client-cert.pem
ssl-key = /etc/mysql/certs/client-key.pem
[sst]
progress=/var/lib/mysql/sst_in_progress
encrypt = 4
ssl-ca = /etc/mysql/certs/ca.pem
ssl-cert = /etc/mysql/certs/server-cert.pem
ssl-key = /etc/mysql/certs/server-key.pem
将配置文件复制到其他节点 scp /etc/my.cnf 10.1.1.22:/etc
,并修改wsrep_node_address的值为对应的节点ip
启动集群
# 启动初始化节点
systemctl start [email protected]
初始化节点配置
# 查询密码
grep 'temporary password' /var/log/mysqld.log
# 初始化设置
mysql_secure_installation
# 登陆配置
mysql -u root -p
# select * from mysql.user where User='root' \G;
update mysql.user set Host='%' where User='root';
flush privileges;
其他节点加入集群
systemctl start mysql
集群查看 show status like 'wsrep_cluster%';
其他
# 安装percona-server
percona-release enable ps-80 release
# percona-release setup ps80
yum install percona-server-server
# 开启防火墙
firewall-cmd --add-port=3306/tcp --add-port=4444/tcp --add-port=4567/tcp --add-port=4568/tcp --permanent
firewall-cmd --reload