MySQL Sandbox - A toolkit for laziness

56
MySQL Sandbox A toolkit for laziness Giuseppe Maxia MySQL Community Team Lead at Oracle 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. Thursday, 15 July 2010

description

MySQL Sandbox presented at the MySQL user Group in San Francisco

Transcript of MySQL Sandbox - A toolkit for laziness

Page 1: MySQL Sandbox - A toolkit for laziness

MySQL SandboxA toolkit for lazinessGiuseppe MaxiaMySQL Community Team Lead at Oracle

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.

Thursday, 15 July 2010

Page 2: MySQL Sandbox - A toolkit for laziness

about me - Giuseppe Maxia• a.k.a. The Data Charmer• MySQL Community Team Lead• Long time hacking with MySQL features• Formerly, database consultant, designer, coder.• A passion for QA• An even greater passion for open source• ... and community• Passionate blogger

•http://datacharmer.blogspot.comThursday, 15 July 2010

Page 3: MySQL Sandbox - A toolkit for laziness

Laziness is a disinclination to activity or exertion despite having the ability to do so.

http://en.wikipedia.org/wiki/Laziness

Laziness

Thursday, 15 July 2010

Page 4: MySQL Sandbox - A toolkit for laziness

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.

Thursday, 15 July 2010

Page 5: MySQL Sandbox - A toolkit for laziness

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.

Thursday, 15 July 2010

Page 6: MySQL Sandbox - A toolkit for laziness

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.

Thursday, 15 July 2010

Page 7: MySQL Sandbox - A toolkit for laziness

I can set up circular replication

• Almost always with errors.

• And cursing.

• Do I feel inclined to do so?

• I DON'T THINK SO.

Thursday, 15 July 2010

Page 8: MySQL Sandbox - A toolkit for laziness

I can install plugins

• After reading the manual.

• And translating from intentions to reality.

• And copying-and-pasting.

• Do I feel inclined to do so?

• I DON'T THINK SO.

Thursday, 15 July 2010

Page 9: MySQL Sandbox - A toolkit for laziness

I have the ability

• but I don't feel inclined to do repetitive work

• I ADMIT IT: I AM LAZY

Thursday, 15 July 2010

Page 10: MySQL Sandbox - A toolkit for laziness

YES: I AM A LAZY

DEVELOPER

Thursday, 15 July 2010

Page 11: MySQL Sandbox - A toolkit for laziness

A lazy developer ®

Someone who writes 12,000 lines of code to save himself the trouble of typing 15 lines on a terminal.

(*) And another 1,000,000 people

(*)

Thursday, 15 July 2010

Page 12: MySQL Sandbox - A toolkit for laziness

That's me

Thursday, 15 July 2010

Page 13: MySQL Sandbox - A toolkit for laziness

And after this presentation,

you will feel lazy too

Thursday, 15 July 2010

Page 14: MySQL Sandbox - A toolkit for laziness

MySQL Sandbox lightning

presentation

Thursday, 15 July 2010

Page 15: MySQL Sandbox - A toolkit for laziness

I used to install a lot of MySQL databases

for testing

MANUALLY

Thursday, 15 July 2010

Page 16: MySQL Sandbox - A toolkit for laziness

Then, I decided to use Perl ...

Thursday, 15 July 2010

Page 17: MySQL Sandbox - A toolkit for laziness

DBA pop quiz

Thursday, 15 July 2010

Page 18: MySQL Sandbox - A toolkit for laziness

HOW MANY KEYSTROKES

to install a MySQL server?

10sb 5.0.831234567890

Thursday, 15 July 2010

Page 19: MySQL Sandbox - A toolkit for laziness

HOW MANY KEYSTROKES

to install 3 MySQL servers in replication?

11sb r5.0.8312345678901

Thursday, 15 July 2010

Page 20: MySQL Sandbox - A toolkit for laziness

HOW LONG does it take

to install a MySQL server?

< 5 secondstime sb 5.0.83

0m1.518sThursday, 15 July 2010

Page 21: MySQL Sandbox - A toolkit for laziness

HOW LONG does it take

to install 3 MySQL servers in replication?

< 10 secondssb 5.0.830m4.515s

Thursday, 15 July 2010

Page 22: MySQL Sandbox - A toolkit for laziness

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

Thursday, 15 July 2010

Page 23: MySQL Sandbox - A toolkit for laziness

Overview

data directory

port

socket

data directory

port

socket

Thursday, 15 July 2010

Page 24: MySQL Sandbox - A toolkit for laziness

Overview

/usr/local/mysql/data

data corruption

same data directory?

/usr/local/mysql/data

Thursday, 15 July 2010

Page 25: MySQL Sandbox - A toolkit for laziness

Overview

3306

/tmp/mysql.sock

does not start

3306

/tmp/mysql.sock

same data port or socket?

Thursday, 15 July 2010

Page 26: MySQL Sandbox - A toolkit for laziness

the hard way1.unpack the tarball2.ensure that it goes to a separate directory3.create the database tables4.create a .cnf file with separate

•port•data directory•socket

5.launch mysqld_safe manually6.launch mysql with options

error prone

Thursday, 15 July 2010

Page 27: MySQL Sandbox - A toolkit for laziness

MySQL Sandbox VERSION

$SANDBOX_HOME/msb_VERSION/data

VERSION

/tmp/mysql_VERSION.sock

Thursday, 15 July 2010

Page 28: MySQL Sandbox - A toolkit for laziness

MySQL Sandbox 5.1.37

$SANDBOX_HOME/msb_5_1_37/data

5137

/tmp/mysql_5137.sock

Thursday, 15 July 2010

Page 29: MySQL Sandbox - A toolkit for laziness

MySQL Sandbox 5.4.1

$SANDBOX_HOME/msb_5_4_1/data

5401

/tmp/mysql_5401.sock

Thursday, 15 July 2010

Page 30: MySQL Sandbox - A toolkit for laziness

MySQL Sandbox

single sandboxcommands

startstopstatusrestartclear

send_kill

use

Thursday, 15 July 2010

Page 31: MySQL Sandbox - A toolkit for laziness

MySQL Sandbox multiple sandboxcommands

One sandbox torule them all

ms1s2

n1n2n3

start_allstop_all

status_allclear_all

send_kill_alluse_all

Thursday, 15 July 2010

Page 32: MySQL Sandbox - A toolkit for laziness

The easy way - installation

# as root$ cpancpan> install MySQL::Sandbox

Thursday, 15 July 2010

Page 33: MySQL Sandbox - A toolkit for laziness

The easy way - single sandbox

$ make_sandbox \ /path/mysql-OS-5.1.37.tar.gz

# that's it!

Thursday, 15 July 2010

Page 34: MySQL Sandbox - A toolkit for laziness

The easy way - replication$ make_replication_sandbox \ /path/mysql-OS-5.1.37.tar.gz

# that's it!

Thursday, 15 July 2010

Page 35: MySQL Sandbox - A toolkit for laziness

default architecture$HOME

/sandboxes opt

mysql

$SANDBOX_HOME

$SANDBOX_BINARY

expandedtarballs

installed sandboxes

Thursday, 15 July 2010

Page 36: MySQL Sandbox - A toolkit for laziness

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

node2Thursday, 15 July 2010

Page 37: MySQL Sandbox - A toolkit for laziness

Thursday, 15 July 2010

Page 38: MySQL Sandbox - A toolkit for laziness

creating a single sanboxmake_sandbox \ /path/to/mysql-X.X.XX-OS.tar.gz

Thursday, 15 July 2010

Page 39: MySQL Sandbox - A toolkit for laziness

using a single sanbox# after # make_sandbox \# /path/to/mysql-X.X.XX-OS.tar.gz

$ cd $SANDBOX_HOME/msb_X_X_XX$ ./use

Thursday, 15 July 2010

Page 40: MySQL Sandbox - A toolkit for laziness

creating a single sanboxwith a specific options file

make_sandbox \ /path/to/mysql-X.X.XX-OS.tar.gz \ --my_file=/path/to/my.cnf

Thursday, 15 July 2010

Page 41: MySQL Sandbox - A toolkit for laziness

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

Thursday, 15 July 2010

Page 42: MySQL Sandbox - A toolkit for laziness

easily create a sandbox after the first one

$ make_sandbox \ path/to/mysql-5.1.34-osx10.5-x86.tar.gz \ --export_binaries

The short way

Thursday, 15 July 2010

Page 43: MySQL Sandbox - A toolkit for laziness

starting a single sanbox$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start

Thursday, 15 July 2010

Page 44: MySQL Sandbox - A toolkit for laziness

starting a single sanboxwith temporary options$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start --option=value

$ ./restart --option=value

$ ./start --key-buffer=20000000

Thursday, 15 July 2010

Page 45: MySQL Sandbox - A toolkit for laziness

creating a sandbox with custom port and directory

$ make_sandbox 5.1.34 \ --sandbox_port=7800 \ --sandbox_directory=mickeymouse

Thursday, 15 July 2010

Page 46: MySQL Sandbox - A toolkit for laziness

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

Thursday, 15 July 2010

Page 47: MySQL Sandbox - A toolkit for laziness

create a replication sandbox

$ make_replication_sandbox \ path/to/mysql-5.1.34-osx10.5-x86.tar.gz

Thursday, 15 July 2010

Page 48: MySQL Sandbox - A toolkit for laziness

create a circular replication sandbox

$ make_replication_sandbox \ --circular=4 \ path/to/mysql-5.1.34-osx10.5-x86.tar.gz

Thursday, 15 July 2010

Page 49: MySQL Sandbox - A toolkit for laziness

changing port to an existing sandbox

$ sbtool -o port \ -s /path/to/source/sandbox \ --new_port=XXXX

Thursday, 15 July 2010

Page 50: MySQL Sandbox - A toolkit for laziness

installing the innodb plugin

$ sbtool -o plugin \ --plugin=innodb \ -s /path/to/source/sandbox

Thursday, 15 July 2010

Page 51: MySQL Sandbox - A toolkit for laziness

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

Thursday, 15 July 2010

Page 52: MySQL Sandbox - A toolkit for laziness

more recipes

$ perldoc MySQL::Sandbox::Recipes

Thursday, 15 July 2010

Page 53: MySQL Sandbox - A toolkit for laziness

Participate!

Thursday, 15 July 2010

Page 54: MySQL Sandbox - A toolkit for laziness

roadmap

66 95

NORTH

SOUTH

EASTWEST

Thursday, 15 July 2010

Page 55: MySQL Sandbox - A toolkit for laziness

roadmap: what's up

• new architecture:

• one deployer class (can install a server)

• subclasses will deploy on different O.S.

• setup wizard for test and production

• Cluster friendly

• Cloud friendly

• written in PythonThursday, 15 July 2010

Page 56: MySQL Sandbox - A toolkit for laziness

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!

Thursday, 15 July 2010