Vagrant + XtraDB Cluster = yay!

So,

in the meantime I had some more time to play around with the XtraDB Cluster. While I used a small 13Mb dump first, I later moved on to a 1.2Gb dump. I think I've managed to convince some colleagues to give it a try as soon as it's stable :) But here's the problem, everyone wants to try it out, but at the same time everyone's too lazy to setup a test environment...

So I've decided to make a simple Vagrantfile that takes care of setting up a 3 node cluster (+ haproxy frontend) with chef-solo. (If you haven't heard of vagrant yet, now's the time to have a look VagrantUp.com !)

Workflow

It's basically as simple as calling vagrant up in the directory where you've checked out the sources from git.

Explanation:

  • If you haven't downloaded the Debian Squeeze Box yet: Vagrant downloads it + add it to the vagrant boxes
  • Creates the first VM for haproxy. As soon as this one is running, you can access the haproxy stats via http://localhost:8080 (user 'admin', password 'admin')
  • Creates the second VM. This will be the first XtraDB Cluster Node (node1). During the installation it looks in the packages directory if there are already the debian packages from Percona. If they aren't: download it & cache them for later use. The first Node is also special, since it doesn't have a "wsrep_cluster_address" set in the my.cnf (=> it doesn't try to join an existing cluster)
  • Creates a VM for node2 and one for node3: Basically the same as node1, but since they have the IP of node1 in "wsrep_cluster_address", they'll join the cluster (hooray!)

Internally used IP Addresses: 10.0.3.10 => node1 10.0.3.20 => node2 10.0.3.30 => node3 10.0.3.40 => haproxy

You can easily access the different VMs via "vagrant ssh #name#"

localhost:3306 is forwarded to haproxy, but before you can use that, you have to create a user on the mysql cluster that can connect from outside (will add that asap in the chef cookbook...). Mysql can be access on the nodes via 'root' and no password

Download

Get&Fork it on Git: https://github.com/derfloh/vagrantXtraDBCluster