安装PXC依赖的PACKAGE(NODE1)

[root@king01 ~]# rpm -ivh epel-release-6-8.noarch.rpm 
[root@king01 ~]# yum install -y bison bison-devel check check-devel boost boost-devel readline readline-devel scons socat perl-DBD-MySQL
[root@king01 ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
[root@king01 ~]# rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm

安装PXC(NODE1)

[root@king01 ~]# tar zxvf Percona-XtraDB-Cluster-5.6.37-82.2.tar.gz
[root@king01 ~]# cd Percona-XtraDB-Cluster-5.6.37-82.2
[root@king01 ~]# cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
[root@king01 Percona-XtraDB-Cluster-5.6.37-82.2]# make && make install
[root@king01 Percona-XtraDB-Cluster-5.6.37-82.2]# cd support-files/ 
[root@king01 support-files]# cp mysql.server /etc/init.d/mysqld

修改PXC参数(NODE1)

[root@king01 ~]#  vi /etc/my.cnf
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=1024M; gcache.page_size=512M"
wsrep_cluster_name = "Percona XtraDB Cluster"
wsrep_cluster_address = "gcomm://192.168.1.201,192.168.1.202,192.168.1.203"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:sst
wsrep_node_name = king01
wsrep_node_address="192.168.1.201"

安装GALERA(NODE1)

[root@king01 ~]# tar zxvf percona-xtradb-cluster-galera-3-3.21.tar.gz
[root@king01 ~]# cd percona-xtradb-cluster-galera-3
[root@king01 percona-xtradb-cluster-galera-3]# scons
[root@king01 percona-xtradb-cluster-galera-3]# cp libgalera_smm.so /usr/local/mysql/lib/
[root@king01 percona-xtradb-cluster-galera-3]# cp garb/garbd /usr/local/mysql/bin/
[root@king01 ~]# cd /usr/local/mysql/
[root@king01 mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@king01 ~]# /etc/init.d/mysqld bootstrap-pxc
[root@king01 ~]# mysql_secure_installation
[root@king01 ~]# mysql -uroot -pabcd.1234
mysql> create user sst@'localhost' identified by 'sst';
Query OK, 0 rows affected (0.10 sec)
mysql> grant reload,lock tables,replication client,process on *.* to  sst@'localhost';
Query OK, 0 rows affected (0.06 sec)
mysql>  flush privileges;
Query OK, 0 rows affected (0.07 sec)
[root@king01 ~]# netstat -tunlp | grep mysqld
tcp        0      0 0.0.0.0:4567                0.0.0.0:*                   LISTEN      24262/mysqld        
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      24262/mysqld

安装PXC依赖的PACKAGE(NODE2)

[root@king02 ~]# rpm -ivh epel-release-6-8.noarch.rpm 
[root@king02 ~]# yum install -y bison bison-devel check check-devel boost boost-devel readline readline-devel scons socat perl-DBD-MySQL
[root@king02 ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
[root@king02 ~]# rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm

安装PXC(NODE2)

[root@king02 ~]# tar zxvf Percona-XtraDB-Cluster-5.6.37-82.2.tar.gz
[root@king02 ~]# cd Percona-XtraDB-Cluster-5.6.37-82.2
[root@king02 ~]# cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
[root@king02 Percona-XtraDB-Cluster-5.6.37-82.2]# make && make install
[root@king02 Percona-XtraDB-Cluster-5.6.37-82.2]# cd support-files/ 
[root@king02 support-files]# cp mysql.server /etc/init.d/mysqld

修改PXC参数(NODE2)

[root@king02 ~]#  vi /etc/my.cnf
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=1024M; gcache.page_size=512M"
wsrep_cluster_name = "Percona XtraDB Cluster"
wsrep_cluster_address = "gcomm://192.168.1.201,192.168.1.202,192.168.1.203"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:sst
wsrep_node_name = king02
wsrep_node_address="192.168.1.202"

安装GALERA(NODE2)

[root@king02 ~]# tar zxvf percona-xtradb-cluster-galera-3-3.21.tar.gz
[root@king02 ~]# cd percona-xtradb-cluster-galera-3
[root@king02 percona-xtradb-cluster-galera-3]# scons
[root@king02 percona-xtradb-cluster-galera-3]# cp libgalera_smm.so /usr/local/mysql/lib/
[root@king02 percona-xtradb-cluster-galera-3]# cp garb/garbd /usr/local/mysql/bin/
root@king02 ~]# cd /usr/local/mysql/
[root@king02 mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@king02 ~]# /etc/init.d/mysqld start
Starting MySQL (Percona XtraDB Cluster)....State transfer in progress, setting sleep higher
......                                                     [  OK  ]
[root@king02 ~]# netstat -tunlp | grep mysqld 
tcp        0      0 0.0.0.0:4567                0.0.0.0:*                   LISTEN      19654/mysqld        
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      19654/mysqld


安装PXC依赖的PACKAGE(NODE3)

[root@king03 ~]# rpm -ivh epel-release-6-8.noarch.rpm 
[root@king03 ~]# yum install -y bison bison-devel check check-devel boost boost-devel readline readline-devel scons socat perl-DBD-MySQL
[root@king03 ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
[root@king03 ~]# rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm
[root@king03 ~]# tar zxvf Percona-XtraDB-Cluster-5.6.37-82.2.tar.gz

安装PXC(NODE3)

[root@king03 ~]# cd Percona-XtraDB-Cluster-5.6.37-82.2
[root@king03 ~]# cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
[root@king03 Percona-XtraDB-Cluster-5.6.37-82.2]# make && make install
[root@king03 Percona-XtraDB-Cluster-5.6.37-82.2]# cd support-files/ 
[root@king03 support-files]# cp mysql.server /etc/init.d/mysqld

修改PXC参数(NODE3)

[root@king03 ~]#  vi /etc/my.cnf
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=1024M; gcache.page_size=512M"
wsrep_cluster_name = "Percona XtraDB Cluster"
wsrep_cluster_address = "gcomm://192.168.1.201,192.168.1.202,192.168.1.203"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:sst
wsrep_node_name = king03
wsrep_node_address="192.168.1.203"

安装GALERA(NODE3)

[root@king03 ~]# tar zxvf percona-xtradb-cluster-galera-3-3.21.tar.gz
[root@king03 ~]# cd percona-xtradb-cluster-galera-3
[root@king03 percona-xtradb-cluster-galera-3]# scons
[root@king03 percona-xtradb-cluster-galera-3]# cp libgalera_smm.so /usr/local/mysql/lib/
[root@king03 percona-xtradb-cluster-galera-3]# cp garb/garbd /usr/local/mysql/bin/
[root@king03 ~]# cd /usr/local/mysql/
[root@king03 mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@king03 ~]# /etc/init.d/mysqld start
Starting MySQL (Percona XtraDB Cluster)....State transfer in progress, setting sleep higher
......                                                     [  OK  ]
[root@king03 ~]# netstat -tunlp | grep mysqld 
tcp        0      0 0.0.0.0:4567                0.0.0.0:*                   LISTEN      21128/mysqld        
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      21128/mysqld


[root@king01 ~]# mysql -uroot -pabcd.1234
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 125
Server version: 5.6.37-82.2-log , wsrep_26.21
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show status like 'wsrep%';

QQ截图20180308231704.png

QQ截图20180308232154.png

QQ截图20180308232053.png