The installation of PXC is very simple!!!!!!
--Software Download
https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/
--Basic Environment preparation
[[email protected] ~]# vim/etc/hosts---Add the following information to the 3 node Hosts file
192.168.2.100 Node1
192.168.2.200 Node2
192.168.2.210 Node3
[Email protected] ~]# rpm-e--nodeps mariadb mariadb-server mariadb-libs Marisa--Uninstall
1, 3 node installation dependent packages
Yum install-y git scons gcc* gcc-c++ openssl* check cmake bison boost-devel asio-devel libaio-devel ncurses-devel Readlin E-devel pam-devel socat perl-time-hires perl-io-socket-ssl.noarch perl-dbd-mysql.x86_64
--Unpack the package and install:
Download the package to note: Remember to select the SSL101 version, the official user manual has the following instructions
[Email protected] ~]# RPM-IVH libev-4.15-1.el6.rf.x86_64.rpm [[email protected] ~]# RPM-IVH percona-xtrabackup-24-2.4. 11-1.el7.x86_64.rpm [[email protected] ~]# tar zxvf percona-xtradb-cluster-5.7.21-rel20-29.26.1.linux.x86_64. Ssl101.tar.gz-c/usr/local/^c[[email protected] ~]# cd/usr/local/[[email protected] local]# ln-s percona-xtradb-cluste R-5.7.21-rel20-29.26.1.linux.x86_64.ssl101.tar.gz Pxc_mysql
2, create a user, new folder, authorize the "three nodes to operate":
[[email protected] ~]# Userdel mysql[[email protected] ~]# useradd-g mysql mysql[[email protected] ~]# passwd Mysql[[emai L protected] ~]# mkdir-p/usr/local/pxc_mysql/{data,logs,tmp}[[email protected] ~]# mkdir-p/usr/local/pxc_mysql/logs/ Binlog[[email protected] ~]# chown-r mysql:mysql/usr/local/pxc_mysql/[[email protected] ~]# chmod-r +x/usr/local/pxc_m ysql/
3, switch the MySQL user to create MY.CNF (the profile is only a few parameters, if the production environment requires more database parameters)
[[email protected] ~]# su - mysql[[email protected] ~]$ cd /usr/ local/pxc_mysql/[[email protected] pxc_mysql]$ vi my.cnf[client]socket=/usr/local/ Pxc_mysql/data[mysqld]server-id=142port = 3306basedir=/usr/local/pxc_mysqldatadir=/usr/local/pxc_ mysql/datasocket=/usr/local/pxc_mysql/data/mysql.socklog-error=/usr/local/pxc_mysql/data/mysqld.logpid-file=/ Usr/local/pxc_mysql/data/mysqld.pidlog-bin=/usr/local/pxc_mysql/logsslow_query_log_file = /usr/local /pxc_mysql/data/slow.loglog_slave_updatesexpire_logs_days=7binlog_format=rowinnodb_buffer_pool_size = 1524m#pxcwsrep_provider=/usr/local/pxc_mysql/lib/libgalera_smm.so wsrep_cluster_name= Pxc-niewsrep_cluster_address=gcomm://192.168.2.100,192.168.2.200,192.168.2.210wsrep_node_name=node1wsrep_node_ Address=192.168.2.100wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth=pxc:123456pxc_strict_mode=enforcing binlog_format=row default_storage_engine=innodbinnodb_autoinc_lock_mode=2
Attention:
The other two nodes need only to be modified:
server-id=142--id can't be the same
Wsrep_node_name=node1--Change to host name of your own node
WSREP_NODE_ADDRESS=192.168.2.100--Change to the host IP of your own node
4. Initialize the database of 3 nodes
/usr/local/pxc_mysql/bin/mysqld--defaults-file=/usr/local/pxc_mysql/my.cnf--datadir=/usr/local/pxc_mysql/data- -basedir=/usr/local/pxc_mysql--initialize
(There is a root password in the/usr/local/pxc_mysql/data/mysqld.log log)
5. Start the first node first:
[Email protected] pxc_mysql]#/usr/local/pxc_mysql/bin/mysqld_safe--defaults-file=/usr/local/pxc_mysql/my.cnf-- Wsrep-new-cluster--user=mysql &---with root
Then go to MySQL, do the following (if not go, the error password expires, then in the my.cnf file added: Skip-grant-tables, and then no password to enter the database: Update mysql.user set password_expired= " N "where user=" root "; Finally remove the parameters from the configuration file, restart the database, with the root password just entered. )
mysql [(None)]> show databases;+--------------------+| database |+--------------------+| information_schema | | mysql | | performance_schema | | sys |+--- -----------------+4 rows in set (0.00 sec) mysql [(none)]> show status like ' wsrep_local_state% '; +---------------------------+-------------------------------------- +| variable_name | value |+------------------ ---------+--------------------------------------+| wsrep_local_state_uuid | c2ab52e7-67cf-11e8-9d02-e76acee85210 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced |+---------------------------+--------------------------------------+3 rows in set (0.00 sec) mysql [(none)]> show status like ' wsrep_cluster_% '; + --------------------------+--------------------------------------+| variable_name | value |+--------------------------+--------------------------------------+| wsrep_ cluster_conf_id | 1 | | wsrep_cluster_size | 1 | | wsrep_cluster_state_uuid | c2ab52e7-67cf-11e8-9d02-e76acee85210 | | wsrep_cluster_status | primary |+ --------------------------+--------------------------------------+4 rows in set (0.00  SEC) mysql [(none)]> grant reload, lock tables, process, replication client on *.* to ' pxc ' @ '% ' IDENTIFIED BY ' 123456 '; ---Create a SST user mysql [(None)]> flush privileges;
(from the above information cluster size is 1 nodes, the state is primary, the node is in the synced state, it is fully connected, can be write-set replication.) )
6. Start the second and third node sequentially:
[Email protected] pxc_mysql]#/usr/local/pxc_mysql/bin/mysqld_safe--defaults-file=/usr/local/pxc_mysql/my.cnf-- User=mysql &
7. Verify Cluster Deployment success:
View at each node:
mysql [(none)]> show status like ' wsrep_cluster_% '; +--------------------------+--- -----------------------------------+| variable_name | Value |+--------------------------+--------------------------------------+| wsrep_cluster_conf_id | 5 | | wsrep_cluster_size | 3 | --- Now 3 nodes are joining the cluster | wsrep_cluster_state_uuid | c2ab52e7-67cf-11e8-9d02-e76acee85210 | | wsrep_cluster_status | Primary |+--------------------------+--------------------------------------+
Create a table or database in one of the nodes to see if 3 nodes are all synchronized.
PXC5.7.21 for linux7.2 Installation