centos8下安裝pxc-80 官方地址 https://www.percona.com/doc/percona-repo-config/index.html https://www.percona.com/doc/percona-xtradb-cluster/LATEST/install/yum ...
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