Testing Percona XtraDB Cluster 8.0 Using Vagrant

Percona XtraDB Cluster 8.0 Using VagrantAs Alkin and Ramesh have shown us in their Testing Percona XtraDB Cluster 8.0 with DBdeployer post, it is now possible to easily deploy an environment to test the features provided by the brand new release of Percona XtraDB Cluster 8.0.

We have also worked on creating a testing environment available for those that use Vagrant instead. Be it that it’s what you are used to working with, or that you want a proper VM for each instance, in particular, you can use the following commands to easily deploy a three-node cluster.

Requirements

Vagrant runs in Linux, Mac OS, and Windows, you just need to have the packages installed. Visit Installing Vagrant if you haven’t done so already.

Apart from this, the only other special mention in this section is CPU and Memory requirements for each node. Make sure to tune the Vagrantfile file if needed, by default the project will use two CPUs and 4Gb of RAM per node:

Download and Setup

To get the project:

Then, to start the nodes:

This will result in having three nodes fully configured, and ready for us to log in. We can do so with the following commands:

After we are logged in, we can access the cluster nodes by simply using the MySQL command-line interface:

We have also included a basic wrapper script that runs sysbench, to be able to generate some load (it will run the cleanup first, then initialization, and finally the OLTP insert workload). To run it as both the vagrant or root OS users:

In the provision.sh script, we created a user with mysql_native_password protocol for use with sysbench, to circumvent these issues.

The result of the sysbench execution will leave ten tables in the sbtest database:

If you want to have more control over what the sysbench script does, feel free to edit the run_sysbench.sh file to your liking.

Cleaning Up

To stop all running VMs, execute:

To terminate and delete all the VMs running, and go back to a clean state, execute:

Network Addendum

To emulate network delay and packet loss between the nodes, we can use the following tc commands (as root). In this case, the eth1 interface was used for communication between the nodes, but double-check with the ip -a command in case it’s different in your setup.

To add a 150-millisecond delay with 5-millisecond uniform distribution:

To add 25 percent packet loss:

Note that, in particular, using 100 percent packet loss is a good way to emulate a “pull the network plug” kind of situation.

To add both delays and packet loss:

And finally, to remove it:

Setting Up More Nodes

To change the number of nodes used in the cluster, just edit the Vagrantfile file and modify the following line to whatever amount of nodes you want:

Using Ansible

If you are an ansible user, you may find the following project interesting, too: https://github.com/nethalo/pxc8

The readme file has information on how you should deploy this environment. In this case, after the nodes are created (with vagrant up) you will need to manually bootstrap the first node, and then start the mysqld services in the remaining two nodes. It needs some additional steps, but it lets you be more involved in the process and helps understand other aspects of the operations side.

Summary

We have seen how to quickly deploy a three-node Percona XtraDB Cluster using Vagrant, how to access the nodes, how to execute MySQL commands, and how to run a sysbench script to generate load. Happy PXC testing!


Percona XtraDB Cluster is a cost-effective and robust clustering solution created to support your business-critical data. It gives you the benefits and features of MySQL along with the added enterprise features of Percona Server for MySQL.

Download Percona XtraDB Cluster Datasheet

Share this post

Leave a Reply