这篇文章主要为大家展示了“PXC5.7版本集群如何安装使用”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“PXC5.7版本集群如何安装使用”这篇文章吧。
 
环境介绍:
 
pxc三个节点:
 
192.168.1.6  test06  
 
192.168.1.7  test07  
 
192.168.1.8  test08
 
操作系统版本:CentOS release 6.8 (Final)
 
在安装pxc之前需要安装如下基础软件包:
 
# yum install -y socat perl-IO-Socket-SSL.noarch perl-DBD-MySQL.x86_64 perl-Time-HiRes openssl openssl-devel
 
关闭防火墙:
 
# service iptables stop
 
yum方式安装:
 
[root@test06 /]# yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
 
Loaded plugins: fastestmirror
 
Setting up Install Process
 
percona-release-0.1-4.noarch.rpm                                                                                       | 6.4 kB     00:00     
 
Examining /var/tmp/yum-root-Km06K3/percona-release-0.1-4.noarch.rpm: percona-release-0.1-4.noarch
 
Marking /var/tmp/yum-root-Km06K3/percona-release-0.1-4.noarch.rpm to be installed
 
Loading mirror speeds from cached hostfile
 
 * base: mirrors.huaweicloud.com
 
 * epel: mirror01.idc.hinet.net
 
 * extras: mirrors.huaweicloud.com
 
 * updates: mirrors.huaweicloud.com
 
Resolving Dependencies
 
--> Running transaction check
 
---> Package percona-release.noarch 0:0.1-4 will be installed
 
--> Finished Dependency Resolution
 
Dependencies Resolved
 
==============================================================================================================================================
 
 Package                            Arch                      Version                  Repository                                        Size
 
==============================================================================================================================================
 
Installing:
 
 percona-release                    noarch                    0.1-4                    /percona-release-0.1-4.noarch                    5.8 k
 
Transaction Summary
 
==============================================================================================================================================
 
Install       1 Package(s)
 
Total size: 5.8 k
 
Installed size: 5.8 k
 
Is this ok [y/N]: y
 
Downloading Packages:
 
Running rpm_check_debug
 
Running Transaction Test
 
Transaction Test Succeeded
 
Running Transaction
 
  Installing : percona-release-0.1-4.noarch                                                                                               1/1
 
  Verifying  : percona-release-0.1-4.noarch                                                                                               1/1
 
Installed:
 
  percona-release.noarch 0:0.1-4                                                                                                              
 
Complete!
 
[root@test data]# yum list | grep Percona-XtraDB-Cluster-57
 
Percona-XtraDB-Cluster-57.x86_64             5.7.23-31.31.2.el6          percona-release-x86_64
 
Percona-XtraDB-Cluster-57-debuginfo.x86_64   5.7.23-31.31.2.el6          percona-release-x86_64
 
[root@test data]# yum install Percona-XtraDB-Cluster-57
 
Loaded plugins: fastestmirror
 
Setting up Install Process
 
Loading mirror speeds from cached hostfile
 
 * base: mirrors.huaweicloud.com
 
 * epel: mirror01.idc.hinet.net
 
 * extras: mirrors.huaweicloud.com
 
 * updates: mirrors.huaweicloud.com
 
Resolving Dependencies
 
--> Running transaction check
 
---> Package Percona-XtraDB-Cluster-57.x86_64 0:5.7.23-31.31.2.el6 will be installed
 
--> Processing Dependency: Percona-XtraDB-Cluster-server-57 = 5.7.23-31.31.2.el6 for package: Percona-XtraDB-Cluster-57-5.7.23-31.31.2.el6.x86_64
 
--> Processing Dependency: Percona-XtraDB-Cluster-client-57 = 5.7.23-31.31.2.el6 for package: Percona-XtraDB-Cluster-57-5.7.23-31.31.2.el6.x86_64
 
--> Running transaction check
 
---> Package Percona-XtraDB-Cluster-client-57.x86_64 0:5.7.23-31.31.2.el6 will be installed
 
---> Package Percona-XtraDB-Cluster-server-57.x86_64 0:5.7.23-31.31.2.el6 will be installed
 
--> Processing Dependency: Percona-XtraDB-Cluster-shared-57 = 5.7.23-31.31.2.el6 for package: Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el6.x86_64
 
--> Processing Dependency: lsof for package: Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el6.x86_64
 
--> Processing Dependency: qpress for package: Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el6.x86_64
 
--> Running transaction check
 
---> Package Percona-XtraDB-Cluster-shared-57.x86_64 0:5.7.23-31.31.2.el6 will be installed
 
---> Package lsof.x86_64 0:4.82-5.el6 will be installed
 
---> Package qpress.x86_64 0:11-1.el6 will be installed
 
--> Finished Dependency Resolution
 
Dependencies Resolved
 
==============================================================================================================================================
 
 Package                                       Arch                Version                          Repository                           Size
 
==============================================================================================================================================
 
Installing:
 
 Percona-XtraDB-Cluster-57                     x86_64              5.7.23-31.31.2.el6               percona-release-x86_64               27 k
 
Installing for dependencies:
 
 Percona-XtraDB-Cluster-client-57              x86_64              5.7.23-31.31.2.el6               percona-release-x86_64              8.6 M
 
 Percona-XtraDB-Cluster-server-57              x86_64              5.7.23-31.31.2.el6               percona-release-x86_64               53 M
 
 Percona-XtraDB-Cluster-shared-57              x86_64              5.7.23-31.31.2.el6               percona-release-x86_64              880 k
 
 lsof                                          x86_64              4.82-5.el6                       base                                324 k
 
 qpress                                        x86_64              11-1.el6                         percona-release-x86_64               30 k
 
Transaction Summary
 
==============================================================================================================================================
 
Install       6 Package(s)
 
Total download size: 63 M
 
Installed size: 64 M
 
Is this ok [y/N]: y
 
Downloading Packages:
 
(1/6): Percona-XtraDB-Cluster-57-5.7.23-31.31.2.el6.x86_64.rpm                                                         |  27 kB     00:00     
 
(2/6): Percona-XtraDB-Cluster-client-57-5.7.23-31.31.2.el6.x86_64.rpm                                                  | 8.6 MB     03:26     
 
(3/6): Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el6.x86_64.rpm                                                  |  53 MB     12:57     
 
(4/6): Percona-XtraDB-Cluster-shared-57-5.7.23-31.31.2.el6.x86_64.rpm                                                  | 880 kB     00:13     
 
(5/6): lsof-4.82-5.el6.x86_64.rpm                                                                                      | 324 kB     00:00     
 
(6/6): qpress-11-1.el6.x86_64.rpm                                                                                      |  30 kB     00:00     
 
----------------------------------------------------------------------------------------------------------------------------------------------
 
Total                                                                                                          64 kB/s |  63 MB     16:43     
 
Running rpm_check_debug
 
Running Transaction Test
 
Transaction Test Succeeded
 
Running Transaction
 
  Installing : Percona-XtraDB-Cluster-client-57-5.7.23-31.31.2.el6.x86_64                                                                 1/6
 
  Installing : Percona-XtraDB-Cluster-shared-57-5.7.23-31.31.2.el6.x86_64                                                                 2/6
 
  Installing : lsof-4.82-5.el6.x86_64                                                                                                     3/6
 
  Installing : qpress-11-1.el6.x86_64                                                                                                     4/6
 
Giving mysqld 5 seconds to exit nicely
 
  Installing : Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el6.x86_64                                                                 5/6
 
 -------------
 
   *  The suggested mysql options and settings are in /etc/percona-xtradb-cluster.conf.d/mysqld.cnf
 
   *  If you want to use mysqld.cnf as default configuration file please make backup of /etc/my.cnf
 
   *  Once it is done please execute the following commands:
 
 rm -rf /etc/my.cnf
 
 update-alternatives --install /etc/my.cnf my.cnf "/etc/percona-xtradb-cluster.cnf" 200
 
 -------------
 
Percona XtraDB Cluster is distributed with several useful UDFs from Percona Toolkit.
 
Run the following commands to create these functions:
 
mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
 
mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
 
mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"
 
See  http://www.percona.com/doc/percona-server/5.7/management/udf_percona_toolkit.html for more details
 
  Installing : Percona-XtraDB-Cluster-57-5.7.23-31.31.2.el6.x86_64                                                                        6/6
 
  Verifying  : Percona-XtraDB-Cluster-client-57-5.7.23-31.31.2.el6.x86_64                                                                 1/6
 
  Verifying  : qpress-11-1.el6.x86_64                                                                                                     2/6
 
  Verifying  : lsof-4.82-5.el6.x86_64                                                                                                     3/6
 
  Verifying  : Percona-XtraDB-Cluster-shared-57-5.7.23-31.31.2.el6.x86_64                                                                 4/6
 
  Verifying  : Percona-XtraDB-Cluster-57-5.7.23-31.31.2.el6.x86_64                                                                        5/6
 
  Verifying  : Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el6.x86_64                                                                 6/6
 
Installed:
 
  Percona-XtraDB-Cluster-57.x86_64 0:5.7.23-31.31.2.el6                                                                                       
 
Dependency Installed:
 
  Percona-XtraDB-Cluster-client-57.x86_64 0:5.7.23-31.31.2.el6          Percona-XtraDB-Cluster-server-57.x86_64 0:5.7.23-31.31.2.el6         
 
  Percona-XtraDB-Cluster-shared-57.x86_64 0:5.7.23-31.31.2.el6          lsof.x86_64 0:4.82-5.el6                                             
 
  qpress.x86_64 0:11-1.el6                                             
 
Complete!
 
主节点配置文件:
 
# vi /etc/my.cnf
 
[mysqld]
 
server-id=216
 
pid-file=/var/run/mysqld/mysqld.pid
 
log-error=/var/log/mysqld.log
 
datadir = /data/mysql/data
 
log_error=/data/mysql/log/mysqld.err
 
wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
 
wsrep_cluster_address=gcomm://192.168.1.6,192.168.1.7,192.168.1.8
 
wsrep_node_name=pxc1
 
wsrep_node_address=192.168.1.6
 
wsrep_slave_threads=2
 
binlog_format=ROW
 
default_storage_engine=InnoDB
 
innodb_autoinc_lock_mode=2
 
wsrep_cluster_name=pxc
 
wsrep_sst_auth=sst:dsf
 
wsrep_sst_method=xtrabackup-v2
 
pxc_strict_mode=ENFORCING
 
~
 
启动主节点pxc:
 
# /etc/init.d/mysql bootstrap-pxc
 
Bootstrapping PXC (Percona XtraDB Cluster)Initializing MySQ[  OK  ]se:  
 
Starting MySQL (Percona XtraDB Cluster). SUCCESS!
 
 
memb {
 
        8c460ee0,0
 
        }
 
joined {
 
        }
 
left {
 
        }
 
partitioned {
 
        }
 
)
 
2018-10-24T08:48:15.976410Z 0 [Note] WSREP: Save the discovered primary-component to disk
 
2018-10-24T08:48:15.977468Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.1.6:4567
 
2018-10-24T08:48:15.977497Z 0 [Note] WSREP: discarding pending addr proto entry 0x3033460
 
2018-10-24T08:48:15.977534Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.1.7:4567
 
2018-10-24T08:48:15.977554Z 0 [Note] WSREP: discarding pending addr proto entry 0x303bc40
 
2018-10-24T08:48:15.977567Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.1.8:4567
 
2018-10-24T08:48:15.977581Z 0 [Note] WSREP: discarding pending addr proto entry 0x3044430
 
2018-10-24T08:48:15.977612Z 0 [Note] WSREP: gcomm: connected
 
2018-10-24T08:48:15.977689Z 0 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
 
2018-10-24T08:48:15.978163Z 0 [Note] WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 0, memb_num = 1
 
2018-10-24T08:48:15.978371Z 0 [Note] WSREP: Waiting for SST/IST to complete.
 
2018-10-24T08:48:15.979995Z 0 [Note] WSREP: Starting new group from scratch: 8c46dd3d-d769-11e8-84c6-d6aac3977406
 
2018-10-24T08:48:15.980513Z 0 [Note] WSREP: STATE_EXCHANGE: sent state UUID: 8c46fb53-d769-11e8-ae76-f615ec681929
 
2018-10-24T08:48:15.980543Z 0 [Note] WSREP: STATE EXCHANGE: sent state msg: 8c46fb53-d769-11e8-ae76-f615ec681929
 
2018-10-24T08:48:15.980550Z 0 [Note] WSREP: STATE EXCHANGE: got state msg: 8c46fb53-d769-11e8-ae76-f615ec681929 from 0 (pxc1)
 
2018-10-24T08:48:15.980558Z 0 [Note] WSREP: Quorum results:
 
        version    = 4,
 
        component  = PRIMARY,
 
        conf_id    = 0,
 
        members    = 1/1 (primary/total),
 
        act_id     = 0,
 
        last_appl. = -1,
 
        protocols  = 0/9/3 (gcs/repl/appl),
 
        group UUID = 8c46dd3d-d769-11e8-84c6-d6aac3977406
 
2018-10-24T08:48:15.980566Z 0 [Note] WSREP: Flow-control interval: [100, 100]
 
2018-10-24T08:48:15.980570Z 0 [Note] WSREP: Trying to continue unpaused monitor
 
2018-10-24T08:48:15.980584Z 0 [Note] WSREP: Restored state OPEN -> JOINED (0)
 
2018-10-24T08:48:15.980611Z 0 [Note] WSREP: Member 0.0 (pxc1) synced with group.
 
2018-10-24T08:48:15.980625Z 0 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 0)

dawei