Using MySQL Sandbox to Test Replication Behavior
It is easy to set up a replication topology with MySQL Sandbox, and I use it for lots of testing scenarios. For example I used MySQL Sandbox to run the tests for yeterday’s post about the way UUIDs are replicated in row-based replication (RBR) versus statement-based replication (SBR).
Here’s how easy it is to set up a replicated sandbox for testing:
Installing MySQL Sandbox
If you’ve never installed MySQL Sandbox before, you can do so by running a single command as root:
1 2 | |
Download the MySQL binary
Pick the appropriate binary based on your OS and the version of MySQL you want to use. In my case I’m on Mac OS X and I want to test MySQL 5.6 so I went to dev.mysql.com and downloaded the following compressed TAR archive:
1
| |
Create the sandbox
This is another one-liner:
1
| |
Use the sandbox
MySQL Sandbox created 3 servers for me: a master and two replicas. Everything is installed under this directory:
1
| |
Here are the relevant my.cnf files:
1 2 3 | |
Here are some handy scripts to start and stop all 3 servers:
1 2 3 | |
And here are the handy scripts to connect to each server with the MySQL CLI:
1 2 3 | |
It’s easy to get confused about which server you are connected to when you are running multiple servers, so MySQL Sandbox overrides the default mysql prompt with a more information prompt. For example here’s the prompt for my master server:
1
| |
Happy testing!
