MySQL SandboxA toolkit for productive lazinessGiuseppe MaxiaQA 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, October 25, 11
about me - Giuseppe Maxia• a.k.a. The Data Charmer• QA Director at Continuent, Inc• Long time hacking with MySQL features• Formerly, community manager,db consultant, designer,
coder.• A passion for QA and open source• Blogger
• http://datacharmer.blogspot.com
Tuesday, October 25, 11
Laziness is a disinclination to activity or exertion despite having the ability to do so.
http://en.wikipedia.org/wiki/Laziness
Laziness
Tuesday, October 25, 11
I am an experienced DBA
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
• In the same host.
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
• In the same host.
• Without conflicting.
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
• In the same host.
• Without conflicting.
• Manually.
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
• In the same host.
• Without conflicting.
• Manually.
• Do I feel inclined to do so?
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
• In the same host.
• Without conflicting.
• Manually.
• Do I feel inclined to do so?
• Several times a day?
Tuesday, October 25, 11
I am an experienced DBA
• I have the ability of installing multiple MySQL servers.
• In the same host.
• Without conflicting.
• Manually.
• Do I feel inclined to do so?
• Several times a day?
• I DON'T THINK SO.
Tuesday, October 25, 11
I am a command line wizard
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
• I can use them
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
• I can use them
• with various long options.
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
• I can use them
• with various long options.
• Manually.
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
• I can use them
• with various long options.
• Manually.
• Do I feel inclined to do so?
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
• I can use them
• with various long options.
• Manually.
• Do I feel inclined to do so?
• Many dozen times a day?
Tuesday, October 25, 11
I am a command line wizard
• After installing multiple servers
• I can use them
• with various long options.
• Manually.
• Do I feel inclined to do so?
• Many dozen times a day?
• I DEFINITELY DON'T THINK SO.
Tuesday, October 25, 11
I can set up replication
Tuesday, October 25, 11
I can set up replication
• Almost without errors.
Tuesday, October 25, 11
I can set up replication
• Almost without errors.
• And then I can connect to masters and slaves with long options on the command line.
Tuesday, October 25, 11
I can set up replication
• Almost without errors.
• And then I can connect to masters and slaves with long options on the command line.
• Do I feel inclined to do so?
Tuesday, October 25, 11
I can set up replication
• Almost without errors.
• And then I can connect to masters and slaves with long options on the command line.
• Do I feel inclined to do so?
• I DON'T THINK SO.
Tuesday, October 25, 11
I have the ability
Tuesday, October 25, 11
I have the ability
• but I don't feel inclined to do repetitive work
Tuesday, October 25, 11
I have the ability
• but I don't feel inclined to do repetitive work
• I ADMIT IT: I AM LAZY
Tuesday, October 25, 11
I have the ability
• but I don't feel inclined to do repetitive work
• I ADMIT IT: I AM LAZY
Tuesday, October 25, 11
A lazy developer ®
Someone who writes 12,000 lines of code to spare himself the trouble of typing 15 lines on a terminal.
Tuesday, October 25, 11
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, October 25, 11
That's me
Tuesday, October 25, 11
MySQL Sandbox
• 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
• Installs IN SECONDS
http://mysqlsandbox.net
Tuesday, October 25, 11
overview
MySQLserver
MySQLserver
Data DB1
DB2 DB3
Data DB1
DB2 DB3DATA DIRECTORY
PORT
SOCKET
Tuesday, October 25, 11
overview
MySQLserver
MySQLserver
Data DB1
DB2 DB3
Data DB1
DB2 DB3
SAME DATA
DIRECTORY?
DATA CORRUPTION
/var/lib/mysql /var/lib/mysql
Tuesday, October 25, 11
overview
MySQLserver
MySQLserver
SAME PORT or SOCKET?
DOES NOT START
/tmp/mysql.sock /tmp/mysql.sock
33063306
Tuesday, October 25, 11
The hard way (1)
Tuesday, October 25, 11
the hard way (2)
Tuesday, October 25, 11
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, October 25, 11
The easier way$ make_sandbox 5.1.54
# Needs some preliminary work
Tuesday, October 25, 11
The easiest way$ sb 5.1.54
# Needs the same preliminary work
Tuesday, October 25, 11
MySQL Sandbox
MySQLserver
VERSION
$SANDBOX_HOME/msb_VERSION/dataData DB1
DB2 DB3
VERSION
/tmp/mysql_VERSION.sock
Tuesday, October 25, 11
MySQL Sandbox
MySQLserver
5.1.54
$SANDBOX_HOME/msb_5_1_54/dataData DB1
DB2 DB3
5154
/tmp/mysql_5154.sock
Tuesday, October 25, 11
MySQL Sandbox
MySQLserver
5.5.9
$SANDBOX_HOME/msb_5_5_09/dataData DB1
DB2 DB3
5509
/tmp/mysql_5509.sock
Tuesday, October 25, 11
Single SandboxMySQLserver
customized scripts
startstop
restartstatusclear
send_killuse
Tuesday, October 25, 11
Multiple SandboxMySQLserver
customized scripts
start_allstop_all
restart_allstatus_allclear_all
send_kill_all
use_all
ms1s2
n1n2n3
Tuesday, October 25, 11
Where do you get it
•from CPANsudo cpan MySQL::Sandbox
•from launchpadhttp://launchpad.net/mysql-sandbox
Tuesday, October 25, 11
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, October 25, 11
default architecture
$HOME
/sandboxes opt
mysql
$SANDBOX_HOME
$SANDBOX_BINARY
expandedtarballs
installed sandboxes
Tuesday, October 25, 11
default architecture
$HOME
/sandboxes opt
mysql
5.0.91
5.1.45
5.1.48
5.5.4
msb_5_0_91
msb_5_1_48
rsandbox_5_1_48
master
node1
node2Tuesday, October 25, 11
Tuesday, October 25, 11
creating a single sandbox
make_sandbox \ /path/to/mysql-X.X.XX-OS.tar.gz
Tuesday, October 25, 11
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, October 25, 11
creating a single sandboxwith a specific options file
make_sandbox \ /path/to/mysql-X.X.XX-OS.tar.gz \ -- --my_file=/path/to/my.cnf
Tuesday, October 25, 11
easily create a sandbox after the first one
$ cd $HOME/opt/mysql$ 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
The long way
# $SANDBOX_BINARY
Tuesday, October 25, 11
easily create a sandbox after the first one
$ make_sandbox --export_binaries \ path/to/mysql-5.1.34-osx10.5-x86.tar.gz
The short way
Tuesday, October 25, 11
starting a single sandbox
$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start
Tuesday, October 25, 11
starting a single sandboxwith temporary options
$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start --option=value
$ ./restart --option=value
$ ./start --key-buffer=20000000
Tuesday, October 25, 11
creating a sandbox with custom port and directory
$ make_sandbox 5.1.34 -- \ --sandbox_port=7800 \ --sandbox_directory=mickeymouse
Tuesday, October 25, 11
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, October 25, 11
create a replication sandbox
$ make_replication_sandbox \ path/to/mysql-5.1.34-osx10.5-x86.tar.gz
Tuesday, October 25, 11
create a circular replication sandbox
$ make_replication_sandbox \ --circular=4 \ path/to/mysql-5.1.34-osx10.5-x86.tar.gz
Tuesday, October 25, 11
changing port to an existing sandbox
$ sbtool -o port \ -s /path/to/source/sandbox \ --new_port=XXXX
Tuesday, October 25, 11
installing the innodb plugin
$ sbtool -o plugin \ --plugin=innodb \ -s /path/to/source/sandbox
Tuesday, October 25, 11
creating a replication sandbox with new base port
$ make_replication_sandbox \ --replication_directory=newwdir \ --check_base_port 5.0.79
# Creates a replication directory under# $SANDBOX_HOME/newdir# The previous one is preserved. # No conflicts happen
Tuesday, October 25, 11
more recipes
$ perldoc MySQL::Sandbox::Recipes
Tuesday, October 25, 11
MySQL Sandbox evolution
Tuesday, October 25, 11
Tungsten Sandbox
Tuesday, October 25, 11
base_dir
database1
database2
database3
replicator1
replicator2
replicator3
TSB
sandboxes
HOME
Tuesday, October 25, 11
tungsten sandbox help./tools/tungsten-sandbox -hUSAGE: ./tools/tungsten-sandbox [flags] argsflags: -n,--nodes: how many nodes to install (default: 3) -m,--mysql_version: which MySQL version to use (default: '5.5.13') -t,--tungsten_base: where to install the sandbox (default: '$HOME/tsb2/') -d,--group_dir: sandbox group directory name (default: 'tr_dbs') -x,--tsb_prefix: Tungsten Sandbox prefix (default: 'db') -s,--service: how the service is named (default: 'tsandbox') -P,--base_port: port base for MySQL sandbox nodes (default: 7100) -l,--thl_port: port for the THL service (default: 12110) -r,--rmi_port: port for the RMI service (default: 10100) -v,--[no]version: show Tungsten sandbox version (default: false) -h,--[no]help: show Tungsten sandbox help (default: false)
Tuesday, October 25, 11
tungsten sandbox$ ./tools/tungsten-sandbox -m 5.5.10executing "clear" on node 1executing "clear" on node 2executing "clear" on node 3installing node 1installing node 2installing node 3group directory installed in $HOME/sandboxes/tr_dbs
Tuesday, October 25, 11
tungsten sandboxls ~/tsb2clear_tsandbox db1 db2 db3 db_clear_all db_send_kill_all db_start_all db_status_all db_stop_all db_use_all n1 n2 n3 replicator_all start_tsandbox trepctl_all
Tuesday, October 25, 11
Participate!
Tuesday, October 25, 11
Participate!
Tuesday, October 25, 11
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.
THANKSLet's talk!
Tuesday, October 25, 11
Top Related