转载来源:https://blog.csdn.net/lvshaorong/article/details/80501905 

pxc集群是Percona XtraDB Cluster的缩写,是基于percona数据库和galera中间件一种特殊MYSQL数据库,而且据说percona数据库的性能要比mysql还要好一些,并且是基于mysql,可以使用mysql的jdbc和客户端进行连接的。

Mysql搭建PXC集群 - Percona XtraDB Cluster

pxc集群相比mysql单一数据库或者mysql主从复制数据库的优点如下

  • 1、所有节点均可读可写,可以轻松的起到HA的作用,任意一台节点宕机都不会影响全局服务
  • 2、在任意一节点写入都是事务强一致性的,不会像主从复制那样使用异步复制的方案导致主从数据不一致的情况。
  • 3、某一个节点宕机之后,再重启恢复后会自动的将宕机期间没有写入的数据补充回来

所以pxc集群不仅可以实现传统的读写分离功能,更在高可用和强一致性上提供了超强的解决方案。大大提高了mysql数据库的可靠性,并且部署还非常简单,下面以基于ubuntu:16.04的docker为例介绍一下在docker部署pxc集群的方法。

官网上也有相关的手册和安装包:https://www.percona.com/software/mysql-database/percona-xtradb-cluster

首先我们需要拉取ubuntu:16.04的操作系统

$ docker pull ubuntu:16.04

然后我们进入这个docker,安装wget和vim,一会会用到

$ docker run -itd ubuntu:16.04 /bin/bash
58470aed38c6569fc5a450a59b18163cbfc47c661c830057caed40e180957b67$ docker attach 5
root@58470aed38c6:/# apt-get update
root@58470aed38c6:/# apt-get install wget vim

然后下载安装Percona XtraDB Cluster的apt源,方便下载相关安装包,注意下面的xenial为ubuntu16.04的代号,要根据操作系统不同而修改

root@58470aed38c6:/# cd /home
root@58470aed38c6:/home# wget https://repo.percona.com/apt/percona-release_0.1-6.xenial_all.deb

你也可以去https://repo.percona.com/apt/手动选择deb包。

然后我们就可以安装这个deb包,并观察有哪些软件包可以安装了

dpkg -i ./percona-release_0.1-6.xenial_all.deb
apt-get update
apt-cache search percona

软件包列表如下

galera-3 - Replication framework for transactional applications
percona-galera-3 - Galera replication framework for Percona XtraDB Cluster
percona-galera-3-dbg - debugging symbols for percona-galera-3
percona-galera-arbitrator-3 - Galera arbitrator daemon for Percona XtraDB Cluster
percona-galera-arbitrator-3-dbg - debugging symbols for percona-galera-arbitrator-3
percona-server-5.6-dbg - Debugging package for Percona Server
percona-server-server - Percona Server database server
percona-server-server-5.6 - Percona Server database server binaries
percona-server-source-5.6 - Percona Server 5.6 source
percona-server-test - Percona Servere regression test suite
percona-server-test-5.6 - Percona Server database test suite
percona-xtrabackup-dbg - Debug symbols for Percona XtraBackup
percona-xtrabackup-test - Test suite for Percona XtraBackup
percona-xtradb-cluster-server - Percona XtraDB Cluster database server
percona-xtradb-cluster-server-5.6 - Percona XtraDB Cluster database server binaries
xtrabackup - Transitional package for percona-xtrabackup
libperconaserverclient18 - Percona Server database client library
libperconaserverclient18-dev - Percona Server database development files
libperconaserverclient18.1 - Percona Server database client library
libperconaserverclient18.1-dev - Percona Server database development files
libperconaserverclient20 - Percona Server database client library
libperconaserverclient20-dev - Percona Server database development files
percona-cacti-templates - Percona Monitoring Plugins for Cacti
percona-nagios-plugins - Percona Monitoring Plugins for Nagios
percona-release - Package to install Percona gpg key and APT repo
percona-server-5.5-dbg - Debugging package for Percona Server
percona-server-5.7-dbg - Debugging package for Percona Server
percona-server-client - Percona Server database client
percona-server-client-5.5 - Percona Server database client binaries
percona-server-client-5.6 - Percona Server database client binaries
percona-server-client-5.7 - Percona Server database client binaries
percona-server-common-5.5 - Percona Server database common files
percona-server-common-5.6 - Percona Server database common files (e.g. /etc/mysql/my.cnf)
percona-server-common-5.7 - Percona Server database common files (e.g. /etc/mysql/my.cnf)
percona-server-mongodb - This metapackage will install the mongo shell, import/export tools, other client utilities, server software, default configuration, and init.d scripts.
percona-server-mongodb-32 - This metapackage will install the mongo shell, import/export tools, other client utilities, server software, default configuration, and init.d scripts.
percona-server-mongodb-32-dbg - Debugging package for Percona Server for MongoDB
percona-server-mongodb-32-mongos - This package contains mongos - the Percona Server for MongoDB sharded cluster query router
percona-server-mongodb-32-server - This package contains the Percona Server for MongoDB server software, default configuration files and init.d scripts
percona-server-mongodb-32-shell - This package contains the Percona Server for MongoDB shell
percona-server-mongodb-32-tools - Mongo tools for high-performance MongoDB fork from Percona
percona-server-mongodb-34 - This metapackage will install the mongo shell, import/export tools, other client utilities, server software, default configuration, and init.d scripts.
percona-server-mongodb-34-dbg - Debugging package for Percona Server for MongoDB
percona-server-mongodb-34-mongos - This package contains mongos - the Percona Server for MongoDB sharded cluster query router
percona-server-mongodb-34-server - This package contains the Percona Server for MongoDB server software, default configuration files and init.d scripts
percona-server-mongodb-34-shell - This package contains the Percona Server for MongoDB shell
percona-server-mongodb-34-tools - Mongo tools for high-performance MongoDB fork from Percona
percona-server-mongodb-36 - This metapackage will install the mongo shell, import/export tools, other client utilities, server software, default configuration, and init.d scripts.
percona-server-mongodb-36-dbg - Debugging package for Percona Server for MongoDB
percona-server-mongodb-36-mongos - This package contains mongos - the Percona Server for MongoDB sharded cluster query router
percona-server-mongodb-36-server - This package contains the Percona Server for MongoDB server software, default configuration files and init.d scripts
percona-server-mongodb-36-shell - This package contains the Percona Server for MongoDB shell
percona-server-mongodb-36-tools - Mongo tools for high-performance MongoDB fork from Percona
percona-server-mongodb-dbg - Debugging package for Percona Server for MongoDB
percona-server-mongodb-mongos - This package contains mongos - the Percona Server for MongoDB sharded cluster query router
percona-server-mongodb-server - This package contains the Percona Server for MongoDB server software, default configuration files and init.d scripts
percona-server-mongodb-shell - This package contains the Percona Server for MongoDB shell
percona-server-mongodb-tools - Mongo tools for high-performance MongoDB fork from Percona
percona-server-rocksdb-5.7 - MyRocks storage engine plugin for Percona Server
percona-server-server-5.5 - Percona Server database server binaries
percona-server-server-5.7 - Percona Server database server binaries
percona-server-source-5.5 - Percona Server 5.5 source
percona-server-source-5.7 - Percona Server 5.7 source
percona-server-test-5.5 - Percona Server database test suite
percona-server-test-5.7 - Percona Server database test suite
percona-server-tokudb-5.6 - TokuDB engine plugin for Percona Server
percona-server-tokudb-5.7 - TokuDB engine plugin for Percona Server
percona-toolkit - Advanced MySQL and system command-line tools
percona-xtrabackup - Open source backup tool for InnoDB and XtraDB
percona-xtrabackup-24 - Open source backup tool for InnoDB and XtraDB
percona-xtrabackup-dbg-24 - Debug symbols for Percona XtraBackup
percona-xtrabackup-test-24 - Test suite for Percona XtraBackup
percona-xtradb-cluster-5.6-dbg - Debugging package for Percona XtraDB Cluster
percona-xtradb-cluster-5.7-dbg - Debugging package for Percona XtraDB Cluster
percona-xtradb-cluster-56 - Percona XtraDB Cluster with Galera
percona-xtradb-cluster-57 - Percona XtraDB Cluster with Galera
percona-xtradb-cluster-client-5.6 - Percona XtraDB Cluster database client binaries
percona-xtradb-cluster-client-5.7 - Percona XtraDB Cluster database client binaries
percona-xtradb-cluster-common-5.6 - Percona XtraDB Cluster database common files (e.g. /etc/mysql/my.cnf)
percona-xtradb-cluster-common-5.7 - Percona XtraDB Cluster database common files (e.g. /etc/mysql/my.cnf)
percona-xtradb-cluster-full-56 - Percona XtraDB Cluster with Galera
percona-xtradb-cluster-full-57 - Percona XtraDB Cluster with Galera
percona-xtradb-cluster-galera-3 - Metapackage for latest version of galera3.
percona-xtradb-cluster-galera-3.x - Galera components of Percona XtraDB Cluster
percona-xtradb-cluster-galera-3.x-dbg - Debugging package for Percona XtraDB Cluster Galera 3.
percona-xtradb-cluster-galera3-dbg - Metapackage for latest version of debug packages.
percona-xtradb-cluster-garbd-3 - Metapackage for latest version of garbd3.
percona-xtradb-cluster-garbd-3.x - Garbd components of Percona XtraDB Cluster
percona-xtradb-cluster-garbd-3.x-dbg - Debugging package for Percona XtraDB Cluster Garbd 3.
percona-xtradb-cluster-garbd-5.7 - Garbd components of Percona XtraDB Cluster
percona-xtradb-cluster-garbd-debug-5.7 - Debugging package for Percona XtraDB Cluster Garbd.
percona-xtradb-cluster-server-5.7 - Percona XtraDB Cluster database server binaries
percona-xtradb-cluster-server-debug-5.6 - Percona XtraDB Cluster database server UNIV_DEBUG binaries
percona-xtradb-cluster-server-debug-5.7 - Percona XtraDB Cluster database server UNIV_DEBUG binaries
percona-xtradb-cluster-source-5.6 - Percona XtraDB Cluster 5.6 source
percona-xtradb-cluster-source-5.7 - Percona XtraDB Cluster 5.7 source
percona-xtradb-cluster-test-5.6 - Percona XtraDB Cluster database test suite
percona-xtradb-cluster-test-5.7 - Percona XtraDB Cluster database test suite
percona-zabbix-templates - Percona Monitoring Plugins for Zabbix
pmm-client - Percona Monitoring and Management Client

可以发现,有很多软件包可以选择,由于建立多节点读写结构的集群需要用到galera插件,所以我们不如一步到位安装完整版本,这样安装大小虽然会有点大,但是不用费脑筋去研究每个包的功能和依赖了,方法如下: 

apt-get install percona-xtradb-cluster-full-57

这样也是官方手册上推荐的方案,大概有下面这些软件包需要安装

The following additional packages will be installed:bzip2 debsums ifupdown iproute iproute2 isc-dhcp-client isc-dhcp-common krb5-locales libaio1 libasn1-8-heimdallibatm1 libboost-program-options1.58.0 libbsd0 libcurl3 libdbd-mysql-perl libdbi-perl libdns-export162 libdpkg-perllibev4 libffi6 libfile-fcntllock-perl libfile-fnmatch-perl libgdbm3 libgmp10 libgnutls30 libgssapi-krb5-2libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdallibisc-export160 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libmecab2libmnl0 libmysqlclient20 libnettle6 libnuma1 libp11-kit0 libperl5.22 libpopt0 libroken18-heimdal librtmp1 libsasl2-2libsasl2-modules libsasl2-modules-db libtasn1-6 libwind0-heimdal libwrap0 libxtables11 lsof mysql-common netbasenetcat-openbsd percona-xtrabackup-24 percona-xtradb-cluster-5.7-dbg percona-xtradb-cluster-client-5.7percona-xtradb-cluster-common-5.7 percona-xtradb-cluster-garbd-5.7 percona-xtradb-cluster-garbd-debug-5.7percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-debug-5.7 percona-xtradb-cluster-test-5.7 perlperl-modules-5.22 psmisc qpress rename rsync socat tcpd ucf xz-utils
Suggested packages:bzip2-doc ppp rdnssd iproute2-doc resolvconf avahi-autoipd isc-dhcp-client-ddns apparmor libclone-perl libmldbm-perllibnet-daemon-perl libsql-statement-perl debian-keyring gcc | c-compiler binutils patch gnutls-bin krb5-dockrb5-user libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql libsasl2-modules-gssapi-mit| libsasl2-modules-gssapi-heimdal tinyca pv perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl makeopenssh-client openssh-server
The following NEW packages will be installed:bzip2 debsums ifupdown iproute iproute2 isc-dhcp-client isc-dhcp-common krb5-locales libaio1 libasn1-8-heimdallibatm1 libboost-program-options1.58.0 libbsd0 libcurl3 libdbd-mysql-perl libdbi-perl libdns-export162 libdpkg-perllibev4 libffi6 libfile-fcntllock-perl libfile-fnmatch-perl libgdbm3 libgmp10 libgnutls30 libgssapi-krb5-2libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdallibisc-export160 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libmecab2libmnl0 libmysqlclient20 libnettle6 libnuma1 libp11-kit0 libperl5.22 libpopt0 libroken18-heimdal librtmp1 libsasl2-2libsasl2-modules libsasl2-modules-db libtasn1-6 libwind0-heimdal libwrap0 libxtables11 lsof mysql-common netbasenetcat-openbsd percona-xtrabackup-24 percona-xtradb-cluster-5.7-dbg percona-xtradb-cluster-client-5.7percona-xtradb-cluster-common-5.7 percona-xtradb-cluster-full-57 percona-xtradb-cluster-garbd-5.7percona-xtradb-cluster-garbd-debug-5.7 percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-debug-5.7percona-xtradb-cluster-test-5.7 perl perl-modules-5.22 psmisc qpress rename rsync socat tcpd ucf xz-utils
0 upgraded, 80 newly installed, 0 to remove and 2 not upgraded.
Need to get 262 MB of archives.
After this operation, 960 MB of additional disk space will be used.

如果网速好的话,等待三五分钟就能安装完毕,然后我们只需简单配置一下配置文件一个pxc集群就搭建好了。

在安装快要结束的时候会需要你输入数据库登陆的root密码

Configuring percona-xtradb-cluster-server-5.7
---------------------------------------------Data directory found when no Percona Server package is installedA data directory '/var/lib/mysql' is present on this system when no MySQL server package is currently installed on the
system. The directory may be under control of server package received from third-party vendors. It may also be an
unclaimed data directory from previous removal of mysql packages.It is highly recommended to take data backup. If you have not done so, now would be the time to take backup in another
shell. Once completed, press 'Ok' to continue.Please provide a strong password that will be set for the root account of your MySQL database. Leave it blank to enable
password less login using UNIX socket based authentication.Enter root password:Now that you have selected a password for the root account, please confirm by typing it again. Do not share the
password with anyone.Re-enter root password:

在安装完毕之后,percona数据库会不自觉的开启,所以我们首先要做的就是关闭

service mysql stop

到这里为止,主从节点都是一样的,下面要根据不同节点写不同的配置文件,并使用不同的启动方式

通过deb包安装的percona数据库不要试图修改/etc/mysql/my.cnf,而要把和节点有关的配置写到/etc/mysql/percona-xtradb-cluster.conf.d/wsrep.cnf里面,这个文件已经给了模板,我们只需稍加修改即可

[mysqld]
# Path to Galera library
wsrep_provider=/usr/lib/galera3/libgalera_smm.so  #这里是galera框架的库地址,需要保证你的磁盘上有这个文件# 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
wsrep_cluster_address=gcomm://172.17.0.2,172.17.0.3,172.7.0.4 #在这里记录集群里所有节点的信息,但不是所有节点都需要开启# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW #只能填ROW# MyISAM storage engine has only experimental support
default_storage_engine=InnoDB# Slave thread to use
wsrep_slave_threads= 8wsrep_log_conflicts# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2# Node IP address
wsrep_node_address=172.17.0.2 #填写当前节点的IP地址
# Cluster name
wsrep_cluster_name=pxc-cluster #填写集群的名字,系群里所有节点都要填的一样#If wsrep_node_name is not specified,  then system hostname will be used
wsrep_node_name=pxc-cluster-node-1 #当前节点的名称,随便填#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
pxc_strict_mode=ENFORCING #开启严格强一致模式,没有主键的表将不能操作# SST method
wsrep_sst_method=xtrabackup-v2#Authentication for SST method
wsrep_sst_auth=sstuser:123456 #设置一个用户名和密码,这个一会开启mysql后还需要手动再配置一遍#主节点和从节点基本配置都是一样的,区别就两行
For the second node:wsrep_node_name=pxc2
wsrep_node_address=172.17.0.3
For the third node:wsrep_node_name=pxc3
wsrep_node_address=172.17.0.4

节点的启动是有讲究的,第一个节点要建立上面配置文件里面写的sstuser用户,并且使用bootstrap启动,其余两个节点都可以简单的启动mysql即可。其中在第一个节点要建立如下用户:

mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY '123456';
mysql> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
mysql> FLUSH PRIVILEGES;

然后就可以开启第一个节点了

/etc/init.d/mysql bootstrap-pxc

然后可以执行一个命令查看当前节点的工作状态,注意另外两个节点不开启也不妨碍当前节点正常工作,在另外两个节点开启后,已经插入的数据会同步到另外两个节点上去。

mysql> show status like 'wsrep%';
+----------------------------+--------------------------------------+
| Variable_name              | Value                                |
+----------------------------+--------------------------------------+
| wsrep_local_state_uuid     | 39e4729d-6345-11e8-8c52-0b4b3546a2be |
| ...                        | ...                                  |
| wsrep_local_state          | 4                                    |
| wsrep_local_state_comment  | Synced                               |
| ...                        | ...                                  |
| wsrep_cluster_size         | 1                                    |
| wsrep_cluster_status       | Primary                              |
| wsrep_connected            | ON                                   |
| ...                        | ...                                  |
| wsrep_ready                | ON                                   |
+----------------------------+--------------------------------------+
40 rows in set (0.01 sec)

开启从节点就简单的多了,只需要把配置文件按照主节点写好,然后启动一下就可以了

/etc/init.d/mysql start

然后在从库上就可以查看当前工作状态

mysql> show status like 'wsrep%';
+----------------------------------+--------------------------------------+
| Variable_name                    | Value                                |
+----------------------------------+--------------------------------------+
| wsrep_local_state_uuid           | 39e4729d-6345-11e8-8c52-0b4b3546a2be |
| wsrep_protocol_version           | 8                                    |
| wsrep_last_applied               | 3                                    |
| wsrep_last_committed             | 3                                    |
| wsrep_replicated                 | 0                                    |
| wsrep_replicated_bytes           | 0                                    |
| wsrep_repl_keys                  | 0                                    |
| wsrep_repl_keys_bytes            | 0                                    |
| wsrep_repl_data_bytes            | 0                                    |
| wsrep_repl_other_bytes           | 0                                    |
| wsrep_received                   | 3                                    |
| wsrep_received_bytes             | 240                                  |
| wsrep_local_commits              | 0                                    |
| wsrep_local_cert_failures        | 0                                    |
| wsrep_local_replays              | 0                                    |
| wsrep_local_send_queue           | 0                                    |
| wsrep_local_send_queue_max       | 1                                    |
| wsrep_local_send_queue_min       | 0                                    |
| wsrep_local_send_queue_avg       | 0.000000                             |
| wsrep_local_recv_queue           | 0                                    |
| wsrep_local_recv_queue_max       | 1                                    |
| wsrep_local_recv_queue_min       | 0                                    |
| wsrep_local_recv_queue_avg       | 0.000000                             |
| wsrep_local_cached_downto        | 0                                    |
| wsrep_flow_control_paused_ns     | 0                                    |
| wsrep_flow_control_paused        | 0.000000                             |
| wsrep_flow_control_sent          | 0                                    |
| wsrep_flow_control_recv          | 0                                    |
| wsrep_flow_control_interval      | [ 141, 141 ]                         |
| wsrep_flow_control_interval_low  | 141                                  |
| wsrep_flow_control_interval_high | 141                                  |
| wsrep_flow_control_status        | OFF                                  |
| wsrep_cert_deps_distance         | 0.000000                             |
| wsrep_apply_oooe                 | 0.000000                             |
| wsrep_apply_oool                 | 0.000000                             |
| wsrep_apply_window               | 0.000000                             |
| wsrep_commit_oooe                | 0.000000                             |
| wsrep_commit_oool                | 0.000000                             |
| wsrep_commit_window              | 0.000000                             |
| wsrep_local_state                | 4                                    |
| wsrep_local_state_comment        | Synced                               |
| wsrep_cert_index_size            | 0                                    |
| wsrep_cert_bucket_count          | 22                                   |
| wsrep_gcache_pool_size           | 1456                                 |
| wsrep_causal_reads               | 0                                    |
| wsrep_cert_interval              | 0.000000                             |
| wsrep_ist_receive_status         |                                      |
| wsrep_ist_receive_seqno_start    | 0                                    |
| wsrep_ist_receive_seqno_current  | 0                                    |
| wsrep_ist_receive_seqno_end      | 0                                    |
| wsrep_incoming_addresses         | 172.17.0.2:3306,172.17.0.3:3306      |
| wsrep_desync_count               | 0                                    |
| wsrep_evs_delayed                |                                      |
| wsrep_evs_evict_list             |                                      |
| wsrep_evs_repl_latency           | 0/0/0/0/0                            |
| wsrep_evs_state                  | OPERATIONAL                          |
| wsrep_gcomm_uuid                 | 84fe5351-6346-11e8-9080-ea323a394028 |
| wsrep_cluster_conf_id            | 2                                    |
| wsrep_cluster_size               | 2                                    |
| wsrep_cluster_state_uuid         | 39e4729d-6345-11e8-8c52-0b4b3546a2be |
| wsrep_cluster_status             | Primary                              |
| wsrep_connected                  | ON                                   |
| wsrep_local_bf_aborts            | 0                                    |
| wsrep_local_index                | 1                                    |
| wsrep_provider_name              | Galera                               |
| wsrep_provider_vendor            | Codership Oy <info@codership.com>    |
| wsrep_provider_version           | 3.26(rac090bc)                       |
| wsrep_ready                      | ON                                   |
+----------------------------------+--------------------------------------+
68 rows in set (0.01 sec)

可以从wsrep_incoming_addresses这一项发现当前有几个激活的了的节点

主库和从库的区别就在于启动方式不一样,谁以bootstrap方式启动谁就是主库,一个从库可以前后隶属于不同的主库,比如一开始跟A是集群,然后我把从库停掉,修改从库的配置文件,把从库归到B集群里,那么在启动过程中就会自动的把从库的数据全部替换为B集群的数据,非常方便,不需要手动干预。

此时我们就可以在主库和从库里写东西,看看两边是否同步了。

像第二个一样,开启第三个节点后,可以在第三个节点上观察集群的运行情况


mysql> show status like 'wsrep%';
+----------------------------------+-------------------------------------------------+
| Variable_name                    | Value                                           |
+----------------------------------+-------------------------------------------------+
| wsrep_local_state_uuid           | 39e4729d-6345-11e8-8c52-0b4b3546a2be            |
| wsrep_protocol_version           | 8                                               |
| wsrep_last_applied               | 4                                               |
| wsrep_last_committed             | 4                                               |
| wsrep_replicated                 | 0                                               |
| wsrep_replicated_bytes           | 0                                               |
| wsrep_repl_keys                  | 0                                               |
| wsrep_repl_keys_bytes            | 0                                               |
| wsrep_repl_data_bytes            | 0                                               |
| wsrep_repl_other_bytes           | 0                                               |
| wsrep_received                   | 3                                               |
| wsrep_received_bytes             | 320                                             |
| wsrep_local_commits              | 0                                               |
| wsrep_local_cert_failures        | 0                                               |
| wsrep_local_replays              | 0                                               |
| wsrep_local_send_queue           | 0                                               |
| wsrep_local_send_queue_max       | 1                                               |
| wsrep_local_send_queue_min       | 0                                               |
| wsrep_local_send_queue_avg       | 0.000000                                        |
| wsrep_local_recv_queue           | 0                                               |
| wsrep_local_recv_queue_max       | 1                                               |
| wsrep_local_recv_queue_min       | 0                                               |
| wsrep_local_recv_queue_avg       | 0.000000                                        |
| wsrep_local_cached_downto        | 0                                               |
| wsrep_flow_control_paused_ns     | 0                                               |
| wsrep_flow_control_paused        | 0.000000                                        |
| wsrep_flow_control_sent          | 0                                               |
| wsrep_flow_control_recv          | 0                                               |
| wsrep_flow_control_interval      | [ 173, 173 ]                                    |
| wsrep_flow_control_interval_low  | 173                                             |
| wsrep_flow_control_interval_high | 173                                             |
| wsrep_flow_control_status        | OFF                                             |
| wsrep_cert_deps_distance         | 0.000000                                        |
| wsrep_apply_oooe                 | 0.000000                                        |
| wsrep_apply_oool                 | 0.000000                                        |
| wsrep_apply_window               | 0.000000                                        |
| wsrep_commit_oooe                | 0.000000                                        |
| wsrep_commit_oool                | 0.000000                                        |
| wsrep_commit_window              | 0.000000                                        |
| wsrep_local_state                | 4                                               |
| wsrep_local_state_comment        | Synced                                          |
| wsrep_cert_index_size            | 0                                               |
| wsrep_cert_bucket_count          | 22                                              |
| wsrep_gcache_pool_size           | 1456                                            |
| wsrep_causal_reads               | 0                                               |
| wsrep_cert_interval              | 0.000000                                        |
| wsrep_ist_receive_status         |                                                 |
| wsrep_ist_receive_seqno_start    | 0                                               |
| wsrep_ist_receive_seqno_current  | 0                                               |
| wsrep_ist_receive_seqno_end      | 0                                               |
| wsrep_incoming_addresses         | 172.17.0.4:3306,172.17.0.2:3306,172.17.0.3:3306 |
| wsrep_desync_count               | 0                                               |
| wsrep_evs_delayed                |                                                 |
| wsrep_evs_evict_list             |                                                 |
| wsrep_evs_repl_latency           | 0/0/0/0/0                                       |
| wsrep_evs_state                  | OPERATIONAL                                     |
| wsrep_gcomm_uuid                 | 0e5b5865-6348-11e8-8a4c-b370847054fd            |
| wsrep_cluster_conf_id            | 3                                               |
| wsrep_cluster_size               | 3                                               |
| wsrep_cluster_state_uuid         | 39e4729d-6345-11e8-8c52-0b4b3546a2be            |
| wsrep_cluster_status             | Primary                                         |
| wsrep_connected                  | ON                                              |
| wsrep_local_bf_aborts            | 0                                               |
| wsrep_local_index                | 0                                               |
| wsrep_provider_name              | Galera                                          |
| wsrep_provider_vendor            | Codership Oy <info@codership.com>               |
| wsrep_provider_version           | 3.26(rac090bc)                                  |
| wsrep_ready                      | ON                                              |
+----------------------------------+-------------------------------------------------+
68 rows in set (0.01 sec)

同时,第三个节点开启之前前两个节点写入的数据都成功同步到了第三节点。

同时,不光从节点可以自由的切换自己所在的集群,主节点也是一样。可以通过启动上的区别加入别的集群成为一个从节点,或者组织新的集群。

----------------------------------------------------------------------------------------------------------------------------

原作者:lvshaorong  转载来源:https://blog.csdn.net/lvshaorong/article/details/80501905

Mysql搭建PXC集群 - Percona XtraDB Cluster相关推荐

  1. MySQL之PXC集群搭建

    一.PXC 介绍 1.1 PXC 简介 PXC 是一套 MySQL 高可用集群解决方案,与传统的基于主从复制模式的集群架构相比 PXC 最突出特点就是解决了诟病已久的数据复制延迟问题,基本上可以达到实 ...

  2. mysql集群重启报错lock_CentOS7.2 下 MySQL 之 PXC 集群部署【Docker+单机多节点】

    背景 [注意]: 鄙人认为本篇适合做入门测试/学习之用,选择的 "单机多节点配置",后面再整理 "多机配置"文章. 近期正突击学习数据库知识 想着对 PXC 集 ...

  3. docker搭建pxc集群

    前言 随着mysql存储的数据量越来越大,mysql查询单表时的响应速度也会随之变慢,尤其是当单节点承载的数据量超出一定的范围后,比如单表超过2000万之后,查询响应速度会下降的很快,因此,一方面可以 ...

  4. CentOS7 下 MySQL 之 PXC 集群部署【Docker+多机多节点】

    背景 最近在进行 MySQL 集群搭建测试的研究中 对于业界主流方案自然不能跳过 在此,整理成完整的文章,希望道友能得到参考价值 - 对于 docker 不熟悉的小伙伴,个人建议移步文章 -- [Ce ...

  5. mysql从节点报错_CentOS7.9 下 MySQL 之 PXC 集群部署【Docker+多机多节点】

    背景 最近在进行 MySQL 集群搭建测试的研究中 对于业界主流方案自然不能跳过 在此,整理成完整的文章,希望道友能得到参考价值 - [注]:Percona XtraDB Cluster(简称 PXC ...

  6. mysql数据库的pxc工具_CentOS7 下 MySQL 数据库 PXC 集群部署操作指导

    背景 最近在进行 MySQL 的 PXC 集群搭建使用和研究 前期已完成了一篇记录文章 : [CentOS7 下 MySQL 之 PXC 集群部署[Docker+多机多节点]] 但是,毕竟不是所有人都 ...

  7. MySQL 部署PXC集群

    目录 MySQL 部署PXC集群 PXC集群概述 PXC介绍 PXC特点 相应端口 主机角色 配置主机名及映射关系 部署PXC 安装软件 配置服务 启动服务 测试配置 测试集群高可用 常见错误 MyS ...

  8. mysql数据库—PXC集群

    1.PXC介绍 Percona XtraDB Cluster(简称PXC) 是基于Galera的MySQL高可用集群解决方案 Galera Cluster是Codership公司开发的一套免费开源的高 ...

  9. Docker搭建MySQL的PXC集群

    一.简介 PXC属于一套近乎完美的mysql高可用集群解决方案,相比那些比较传统的基于主从复制模式的集群架构MHA和MM+keepalived,galera cluster最突出特点就是解决了诟病已久 ...

最新文章

  1. 刷题百道却跪在白板面试?白板面试FAQ为你答疑解惑
  2. new Scanner(1.txt);读取不到文件中的数据
  3. 2.3.2 Batch Norm介绍
  4. 使用ML.NET + Azure DevOps + Azure Container Instances打造机器学习生产化
  5. 小区物业费信息管理系统设计c++_律师,我没有签物业合同,可以不交物业费吗?...
  6. 开放下载 | 《Knative 云原生应用开发指南》开启云原生时代 Serverless 之门
  7. 区分一下强制类型转换运算符重载/赋值运算符重载/对象定义的赋值
  8. C#:RichTextBox 追加其它颜色的行列
  9. linux mysql5.6 安装
  10. 创建、修改、删除表总结
  11. wireshark 过滤表达式
  12. 零基础带你学习MySQL—创建表(四)
  13. DropDownList下拉框多选
  14. 计算机主机和音箱之间的接口电路是(),《多媒体技术及应用》按章复习题
  15. 代购类网站商品高清晰大图片(1000x1000)的采集解决方案 - hackercai - 博客园
  16. 微信小程序picker下拉框
  17. mysql容灾方案_mysql 架构 ~异地容灾
  18. FreeBSD内核配置文件详解 (转)
  19. JAVA图形化打字小游戏
  20. 完美解决:Chrome浏览器无法自动保存/填充密码

热门文章

  1. php csv to array (csv 转数组)
  2. Linux开启路由转发功能
  3. LeetCode 496. Next Greater Element I
  4. 【今日CV 计算机视觉论文速览】 25 Feb 2019
  5. linux 命令行使用wget下载百度云资源
  6. 上机 文件读写器 c# 1614998685
  7. django-orm查询-验证是否存在的方式
  8. django-阻止某一个IP访问某一个页面
  9. centos-修改分辨率
  10. linux-目录查询命令-目录内容查看-ls查询-tree查询-查询类容分类-不同颜色对应不同类型