KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
Testing mysql creatively in a sandbox
1. Testing MySQL
Creatively in a sandbox
Giuseppe Maxia
QA Director, Continuent, Inc
This work is licensed under the Creative Commons
Attribution-Share Alike 3.0 Unported License. To view a
copy of this license, visit http://creativecommons.org/
licenses/by-sa/3.0/ or send a letter to Creative Commons,
171 Second Street, Suite 300, San Francisco, California,
94105, USA.
Tuesday, February 7, 12 1
2. Laziness
Laziness is a disinclination to
activity or exertion despite
having the ability to do so.
http://en.wikipedia.org/wiki/Laziness
Tuesday, February 7, 12 2
3. I have the ability
• but I don't feel inclined to do repetitive
work
• I ADMIT IT: I AM LAZY
Tuesday, February 7, 12 3
4. I have the ability
• but I don't feel inclined to do repetitive
work
• I ADMIT IT: I AM LAZY
Tuesday, February 7, 12 3
5. A lazy developer ®
Someone who writes 12,000
lines of code to spare himself (*)
the trouble of typing 15 lines
on a terminal.
(*) And another 1,000,000 people
Tuesday, February 7, 12 4
6. MySQL Sandbox
http://mysqlsandbox.net
• Free software (Perl under GPL)
• One (unix) host
• Many database servers
• Single or multiple sandboxes
• Customized scripts to use the servers
• Standard or circular replication
• Supports MySQL, Percona, MariaDB servers
• Installs IN SECONDS
Tuesday, February 7, 12 5
7. overview
MySQL MySQL
server server
Data DB1 Data DB1
DB2 DB3
DATA DIRECTORY DB2 DB3
PORT
SOCKET
Tuesday, February 7, 12 6
8. overview
MySQL MySQL
server server
Data DB1
SAME Data DB1
DB2 DB3
DATA DB2 DB3
DIRECTORY?
/var/lib/mysql /var/lib/mysql
DATA CORRUPTION
Tuesday, February 7, 12 7
9. overview
MySQL MySQL
server server
SAME
PORT or
SOCKET?
3306 3306
/tmp/mysql.sock /tmp/mysql.sock
DOES NOT START
Tuesday, February 7, 12 8
10. The easy way
$ make_sandbox
/path/to/mysql-5.1.54_linux.tar.gz
$ make_sandbox
Percona-Server-5.1.54_linux.tar.gz
# it should work always
Tuesday, February 7, 12 9
11. The easier way
$ make_sandbox 5.1.54
# Needs some preliminary work
Tuesday, February 7, 12 10
12. The easiest way
$ sb 5.1.54
# Needs the same preliminary work
Tuesday, February 7, 12 11
13. MySQL Sandbox
VERSION
MySQL
server
Data DB1
DB2 DB3
$SANDBOX_HOME/msb_VERSION/data
VERSION
/tmp/mysql_VERSION.sock
Tuesday, February 7, 12 12
14. MySQL Sandbox
5.1.54
MySQL
server
Data DB1
DB2 DB3
$SANDBOX_HOME/msb_5_1_54/data
5154
/tmp/mysql_5154.sock
Tuesday, February 7, 12 13
15. MySQL Sandbox
5.5.9
MySQL
server
Data DB1
DB2 DB3
$SANDBOX_HOME/msb_5_5_09/data
5509
/tmp/mysql_5509.sock
Tuesday, February 7, 12 14
16. Single Sandbox
MySQL customized scripts
server
start
stop
restart
status
clear
send_kill
use
Tuesday, February 7, 12 15
17. Multiple Sandbox
MySQL customized scripts
server
start_all
stop_all
restart_all m n1
status_all s1 n2
clear_all s2 n3
send_kill_a
ll
use_all
Tuesday, February 7, 12 16
18. Where do you get it
•from CPAN
$ sudo su -
# cpan MySQL::Sandbox
•from launchpad
http://launchpad.net/mysql-sandbox
Tuesday, February 7, 12 17
19. The easy replication way
$ make_replication_sandbox
/path/to/mysql-5.1.54_linux.tar.gz
# or, after some preparation
$ make_replication_sandbox 5.1.54
Tuesday, February 7, 12 18
20. default architecture
$HOME
/sandboxes opt
expanded
tarballs
$SANDBOX_HOME
mysql
$SANDBOX_BINARY
installed
sandboxes
Tuesday, February 7, 12 19
23. creating a single sandbox
make_sandbox
/path/to/mysql-X.X.XX-OS.tar.gz
Tuesday, February 7, 12 22
24. using a single sandbox
# after
# make_sandbox
# /path/to/mysql-X.X.XX-OS.tar.gz
$ cd $SANDBOX_HOME/msb_X_X_XX
$ ./use
Tuesday, February 7, 12 23
25. creating a single sandbox
with a specific options file
make_sandbox
/path/to/mysql-X.X.XX-OS.tar.gz
-- --my_file=/path/to/my.cnf
Tuesday, February 7, 12 24
26. easily create a sandbox after the first
one
The long way
$ cd $HOME/opt/mysql # $SANDBOX_BINARY
$ gunzip -c
/path/to/mysql-5.1.34-osx10.5-x86.tar.gz
| tar -xf -
$ mv mysql-5.1.34-osx10.5-x86 5.1.34
$ make sandbox 5.1.34
Tuesday, February 7, 12 25
27. easily create a sandbox after the first
one
The short way
$ make_sandbox --export_binaries
path/to/mysql-5.1.34-osx10.5-x86.tar.gz
Tuesday, February 7, 12 26
28. starting a single sandbox
$ cd $SANDBOX_HOME/msb_X_X_XX
$ ./start
Tuesday, February 7, 12 27
29. starting a single sandbox
with temporary options
$ cd $SANDBOX_HOME/msb_X_X_XX
$ ./start --option=value
$ ./restart --option=value
$ ./start --key-buffer=20000000
Tuesday, February 7, 12 28
30. creating a sandbox with custom port
and directory
$ make_sandbox 5.1.34 --
--sandbox_port=7800
--sandbox_directory=mickeymouse
Tuesday, February 7, 12 29
31. creating a sandbox with automatic
port checking
$ make_sandbox 5.1.34 -- --check_port
# if 5.1.34 is free
# port=5134
# directory=msb_5_1_34
# else
# port=5135 (or the first free)
# directory=msb_5_1_34_a
Tuesday, February 7, 12 30
32. create a replication sandbox
$ make_replication_sandbox
path/to/mysql-5.1.34-osx10.5-x86.tar.gz
Tuesday, February 7, 12 31
33. changing port to an existing sandbox
$ sbtool -o port
-s /path/to/source/sandbox
--new_port=XXXX
Tuesday, February 7, 12 32
34. more recipes
$ perldoc MySQL::Sandbox::Recipes
Tuesday, February 7, 12 33
36. More flexible
• make_sandbox
• --high_performance
• --master (creates a standalone master)
• --slaveof (makes a quick slave of an
existing server, even of different versions)
Tuesday, February 7, 12 35
37. create a customized replication
system
$ make_sandbox 5.1.57 -- --master
$ make_sandbox 5.5.18
-- --slaveof='master_port=5157'
$ make_sandbox 5.6.3
-- --slaveof='master_port=5157'
Tuesday, February 7, 12 36
38. Easier to integrate in other
systems
• make_multiple_sandbox,
make_replication_sandbox
• --node_options='options'
• --one_slave_option='N:options'
• --one_node_option='N:options'
• --master_options='options'
• --slave_options='options'
Tuesday, February 7, 12 37
41. tungsten sandbox help
Tungsten Tools, version 2.0.07
Tungsten Sandbox - Cluster builder
(C) 2011 Giuseppe Maxia, Continuent, Inc
Syntax: /home/tungsten/bin/tungsten-sandbox [options] operation
-n --nodes = number How many nodes to install
-m --mysql-version = name which MySQL version to use
-t --tungsten-base = name Where to install the sandbox
-i --installation-directory = name Where the Tungsten tarball has been expanded
-d --group-dir = name sandbox group directory name
--topology = name Which topology to deploy
--hub = number Which node is a hub
-s --service = name How the service is named
-x --tsb-prefix = name Tungsten Sandbox prefix
-p --base-port = number Base port for MySQL Sandbox nodes
-l --thl-port = number Port for the THL service
-r --rmi-port = number Port for the RMI service
-v --version Show Tungsten sandbox version and exit
--show-options Show Tungsten sandbox collected options and exit
--ignore-manifest Ignore build values in .manifest when determining if
the Tungsten package
can be used with this sandbox
--verbose Show more information during installation and help
--man|manual display the program manual
--install-options = name Options to be passed to the underlying installer,
with the format
{TR|MSB}:ROLE:options
Where TR is Tungsten Replicator, MSB is MySQL
Sandbox, and ROLE can be
one of MASTER, SLAVE, DIRECT, NODE, HUB, ENDPOINT,
GLOBAL
-h --help display this help
Tuesday, February 7, 12 40
46. THANKS
Let's talk!
This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit http://
creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California,
94105, USA.
Tuesday, February 7, 12 45