vim /etc/hosts
vim /etc/selinux/config
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=4567/tcp --permanent
firewall-cmd --zone=public --add-port=4568/tcp --permanent
firewall-cmd --zone=public --add-port=4444/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-port
首先卸载已安装的mysql
rpm -qa | grep mysql
rpm -e 服务名
sudo rpm -Uvh https://www.percona.com/downloads/percona-release/redhat/latest
sudo yum install Percona-XtraDB-Cluster-57
sudo yum install Percona-XtraDB-Cluster-garbd-57
sudo rpm -Uvh https://www.percona.com/downloads/percona-release/redhat/latest
sudo yum install Percona-XtraDB-Cluster-57
修改mysql的配置
vim /etc/percona-xtradb-cluster.conf.d/mysqld.cnf
#Template my.cnf for PXC
#Edit to your requirements.
[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
server-id=199
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log-bin
log_slave_updates
expire_logs_days=7
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log_bin_trust_function_creators=on
character_set_server = utf8
collation_server = utf8_bin
vim /etc/percona-xtradb-cluster.conf.d/wsrep.cnf
[mysqld]
#Path to Galera library
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
#Cluster connection URL contains IPs of nodes
#If no IP is found, this implies that a new cluster needs to be created,
#in order to do that you need to bootstrap this node 所有节点的ip地址
wsrep_cluster_address=gcomm://192.168.31.199,192.168.31.197,192.168.31.198
#In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW
#MyISAM storage engine has only experimental support
default_storage_engine=InnoDB
#Slave thread to use
wsrep_slave_threads= 8
wsrep_log_conflicts
#This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2
#Node IP address 当前节点的ip
wsrep_node_address=192.168.31.199
#Cluster name 统一的集群名称
wsrep_cluster_name=pxc-cluster
#If wsrep_node_name is not specified, then system hostname will be used 当前节点的名称
wsrep_node_name=pxc-node-199
#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
pxc_strict_mode=PERMISSIVE
#SST method
wsrep_sst_method=xtrabackup-v2
#Authentication for SST method 这里是mysql用于同步数据的账户需要在所有节点上都注册该账户,账户:密码
wsrep_sst_auth=“sstuser:s3cretPass”
启动第一个主节点mysql服务
systemctl start [email protected]
修改密码创建用户查看这篇文章
https://blog.csdn.net/zhaohan___/article/details/105794735
启动剩余节点
service mysql start
查看集群状态
show status like ‘%wsrep_clust%’;