This blog post will help you configure a 3-node Percona XtraDB Cluster using a binary tarball on your local machine. Configuration files are auto-generated with mostly default configurations except for port/IP address details. The tool has the handy script to create configuration files and start multiple Percona XtraDB Cluster nodes on the fly, helping you to start PXC quickly without spending time on startup configuration as well as avoid using any virtual environments. The script is available in the percona-qa github project. Currently, this script supports PXC binary tarball distributions only.
You can download the appropriate tarball package from the Percona-XtraDB-Cluster-8.0 downloads page. Once you have the packages available on your local machine, unpack the tarball package.
Note: You can use the DBDeployer tool to deploy PXC-5.7 servers easily. pxc-startup.sh script also works with PXC-5.7 packages.
Now we need to run the pxc-startup.sh script from the Percona XtraDB Cluster base directory. It will check out the PXC startup script called start_pxc.
The following steps will help you to start a 3-node PXC in CentOS 7.
1. Checkout pxc-startup.sh repo:
wget https://raw.githubusercontent.com/Percona-QA/percona-qa/master/pxc-tests/pxc-startup.sh
2. Download PXC binary tarball packages for CentOS7 (In this blog we will be using the PXC-8.0 experimental package):
wget https://www.percona.com/redir/downloads/TESTING/Percona-XtraDB-Cluster-8.0/centos7/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102.tar.gz
3. Unpack tarball package and run pxc-startup.sh script from Percona XtraDB Cluster base directory:
tar -xzf Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102.tar.gz $ cd Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/ $ bash ../pxc-startup.sh Added scripts: ./start_pxc ./start_pxc will create ./stop_pxc | ./*node_cli | ./wipe scripts $
4. If you want to start the 3-node cluster, please use numeric 3 as parameter with ./start_pxc:
$ ./start_pxc 3 Starting PXC nodes… Server on socket /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node1/socket.sock with datadir /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node1 started Configuration file : /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node1.cnf Server on socket /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node2/socket.sock with datadir /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node2 started Configuration file : /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node2.cnf Server on socket /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node3/socket.sock with datadir /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node3 started Configuration file : /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node3.cnf $
The start_pxc script will also create shutdown(stop)/wipe/cli sanity scripts.
$ ls -1 *_node_cli wipe *_pxc 1_node_cli 2_node_cli 3_node_cli start_pxc stop_pxc wipe $
The ./stop_pxc script will stop all cluster nodes.
$ ./stop_pxc Server on socket /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node3/socket.sock with datadir /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node3 halted Server on socket /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node2/socket.sock with datadir /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node2 halted Server on socket /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node1/socket.sock with datadir /home/vagrant/Percona-XtraDB-Cluster_8.0.15.5-27dev.4.2_Linux.x86_64.ssl102/node1 halted $
The ./[1-3]_node_cli scripts will help to login to the respective node using the MySQL client.
$ ./1_node_cli [..] node1:root@localhost> show status like 'wsrep_cluster_size'; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | wsrep_cluster_size | 3 | +--------------------+-------+ 1 row in set (0.03 sec) node1:root@localhost>
The ./wipe script will trigger stop_pxc script and move the data directory to .PREV.
$ ls -d1 *.PREV node1.PREV node2.PREV node3.PREV $
The configuration files will be created in the base directory. You can also add custom configurations in the start_pxc script.
$ ls -1 *.cnf node1.cnf node2.cnf node3.cnf $