PXC (Percona-XtraDB-Cluster) 5.7 version cluster deployment
Centos 7.3 Mysql cluster system deployment
PXC performed separately and mounted three nodes
(1) configure the hosts
cat /etc/hosts
172.16.2.10 node1
172.16.2.11 node2
172.16.2.12 node3
(2) reliance
yum –y remove mariadb-*
yum -y install gcc gcc-c++ perl-IO-Socket-SSL.noarch perl-DBD-MySQL.x86_64 perl-Time-HiRes openssl* openssl-devel libcurl-devel wget
(3) Download Percona XtraBackup 2.4
wget https://www.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.10/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm yum -y localinstall percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm
(4) and is mounted Percona Release Socat
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
(5) Installation PXC 5.7 binaries
wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/Percona-XtraDB-Cluster-5.7.21-29.26/binary/tarball/Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1:102.tar.gz
tar -xf Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1_102.tar.gz -C /usr/local/
mv /usr/local/Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1\:102 /usr/local/mysql
useradd -s /sbin/nologin mysql
chown mysql.mysql -R /usr/local/mysql
mkdir -p /data/mysql/data
chown mysql.mysql -R /data/mysql/
echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
Configure the first machine, and the successful launch, the other two in the configuration
to create a profile on the first host:
vim /etc/my.cnf [client] port = 3306 socket= /data/mysql/mysql.sock default-character-set=utf8 [mysqld] basedir = /usr/local/mysql datadir = /data/mysql/data pid-file = /data/mysql/mysql.pid character-set-server=utf8 init_connect = 'SET NAMES utf8' log-bin=/data/mysql/log_bin server-id = 101 innodb_buffer_pool_size = 100M the innodb_data_file_path = ibdata1: 1OM: AUTOEXTEND the innodb_data_home_dir = / Data / MySQL the innodb_file_per_table = . 1 Skip -name- Resolve Port = 3306 Socket = / Data / MySQL / mysql.sock User = MySQL log_error action = mysql_error.log #pxc binlog_format = the ROW wsrep_cluster_address Gcomm =: // 172.16.2.10,172.16.2.11,172.16.2.12 # three nodes remain the same wsrep_provider = / usr / local / MySQL / lib / libgalera_smm.so wsrep_node_address =172.16 . 2.10 # modified according to different ip of the Node wsrep_slave_threads = 2 wsrep_cluster_name = pxc_mysql # same cluster This value needs to be consistent wsrep_sst_method = xtrabackup- v2 wsrep_node_name = Node_1 # different nodes to modify a different name innodb_autoinc_lock_mode = 2 wsrep_sst_auth = " sstuser: pxcmysql " log -slave- Updates [MySQL] NO -auto- the rehash default -character- SET = UTF8
This written document, spread to two other machines / etc below,
each host server-id and wsrep_node_address, wsrep_node_name can remain different
Initialization mysql5.7 :( initialization is executed only at the first node)
mysqld --initialize --user=mysql --datadir=/data/mysql/data
Initialization parameters --initialize-insecure, this will not set the initialization root password, if it is --initialize then, it will generate a random password
grep "password" /data/mysql/data/error.log
Mysql5.7 start PXC
node1 on:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --wsrep-new-cluster --user=mysql &
New transfer user:
grant all privileges on *.* to 'sstuser'@'localhost' identified by 'pxcmysql';(一定要localhost) flush privileges;
View cluster status
show status like 'wsrep%';
Mounting the other nodes, the specific steps to view the previous step
SCP-Percona xtrabackup-24-2.4.10-1.el7.x86_64.rpm 172.16.2.11:/root
SCP-Percona xtrabackup-24-2.4.10-1.el7.x86_64. 172.16.2.12:/root RPM
SCP-Percona the XtraDB-rel20-29.26.1.Linux.x86_64.ssl1_102.tar.gz 172.16.2.11:/root the Cluster-5.7.21-
SCP-Percona-the XtraDB the Cluster-5.7.21- 172.16.2.12:/root rel20-29.26.1.Linux.x86_64.ssl1_102.tar.gz
scp /etc/my.cnf 172.16.2.11:/etc/
scp /etc/my.cnf 172.16.2.12:/etc/
node2 and node3 start (no need to initialize)
/usr/local/mysql/bin/mysqld_safe –-defaults-file=/etc/my.cnf &
Repeatedly stepped pit PXC deployment cluster:
(1) According to the official website of the document /etc/init.d/mysql bootstrap-pxc has failed to start
Solution: a version of the problem began to suspect is PXC, for the two small version 5.7 is still the same error, and finally use the / usr / local / mysql / bin / mysqld_safe mode starts successfully
(2) Start jnode3 given node: [ERROR] WSREP: Command did not run: wsrep_sst_xtrabackup-v2 --role 'donor' --address' 172.16.2.12:4444/xtrabackup_sst
Resolution: Modify node3 profile, with wsrep_sst_method = rsync startup, normal start synchronization data is completed, the shutdown node2; node2 then modify the wsrep_sst_method = xtrabackup-v2, may initiate data synchronization normally
The above workaround hope for your help, the solution is hard to come by, of many experiments.