Top Banner
MySQL Sandbox A toolkit for productive laziness 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, October 25, 11
74

MySQL Sandbox - A toolkit for productive laziness

Nov 07, 2014

Download

Technology

Giuseppe Maxia

Presentation on MySQL Sandbox at Percona Live, London 2011
How to install several MySQL servers in the same host, either stand-alone or in groups, easily and painlessly
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MySQL Sandbox - A toolkit for productive laziness

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

Page 2: MySQL Sandbox - A toolkit for productive laziness

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

Page 3: MySQL Sandbox - A toolkit for productive laziness

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

Page 4: MySQL Sandbox - A toolkit for productive laziness

I am an experienced DBA

Tuesday, October 25, 11

Page 5: MySQL Sandbox - A toolkit for productive laziness

I am an experienced DBA

• I have the ability of installing multiple MySQL servers.

Tuesday, October 25, 11

Page 6: MySQL Sandbox - A toolkit for productive laziness

I am an experienced DBA

• I have the ability of installing multiple MySQL servers.

• In the same host.

Tuesday, October 25, 11

Page 7: MySQL Sandbox - A toolkit for productive laziness

I am an experienced DBA

• I have the ability of installing multiple MySQL servers.

• In the same host.

• Without conflicting.

Tuesday, October 25, 11

Page 8: MySQL Sandbox - A toolkit for productive laziness

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

Page 9: MySQL Sandbox - A toolkit for productive 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?

Tuesday, October 25, 11

Page 10: MySQL Sandbox - A toolkit for productive 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?

Tuesday, October 25, 11

Page 11: MySQL Sandbox - A toolkit for productive 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.

Tuesday, October 25, 11

Page 12: MySQL Sandbox - A toolkit for productive laziness

I am a command line wizard

Tuesday, October 25, 11

Page 13: MySQL Sandbox - A toolkit for productive laziness

I am a command line wizard

• After installing multiple servers

Tuesday, October 25, 11

Page 14: MySQL Sandbox - A toolkit for productive laziness

I am a command line wizard

• After installing multiple servers

• I can use them

Tuesday, October 25, 11

Page 15: MySQL Sandbox - A toolkit for productive laziness

I am a command line wizard

• After installing multiple servers

• I can use them

• with various long options.

Tuesday, October 25, 11

Page 16: MySQL Sandbox - A toolkit for productive laziness

I am a command line wizard

• After installing multiple servers

• I can use them

• with various long options.

• Manually.

Tuesday, October 25, 11

Page 17: MySQL Sandbox - A toolkit for productive 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?

Tuesday, October 25, 11

Page 18: MySQL Sandbox - A toolkit for productive 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?

Tuesday, October 25, 11

Page 19: MySQL Sandbox - A toolkit for productive 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.

Tuesday, October 25, 11

Page 20: MySQL Sandbox - A toolkit for productive laziness

I can set up replication

Tuesday, October 25, 11

Page 21: MySQL Sandbox - A toolkit for productive laziness

I can set up replication

• Almost without errors.

Tuesday, October 25, 11

Page 22: MySQL Sandbox - A toolkit for productive 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.

Tuesday, October 25, 11

Page 23: MySQL Sandbox - A toolkit for productive 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?

Tuesday, October 25, 11

Page 24: MySQL Sandbox - A toolkit for productive 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.

Tuesday, October 25, 11

Page 25: MySQL Sandbox - A toolkit for productive laziness

I have the ability

Tuesday, October 25, 11

Page 26: MySQL Sandbox - A toolkit for productive laziness

I have the ability

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

Tuesday, October 25, 11

Page 27: MySQL Sandbox - A toolkit for productive laziness

I have the ability

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

• I ADMIT IT: I AM LAZY

Tuesday, October 25, 11

Page 28: MySQL Sandbox - A toolkit for productive laziness

I have the ability

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

• I ADMIT IT: I AM LAZY

Tuesday, October 25, 11

Page 29: MySQL Sandbox - A toolkit for productive laziness

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

Page 30: MySQL Sandbox - A toolkit for productive laziness

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

Page 31: MySQL Sandbox - A toolkit for productive laziness

That's me

Tuesday, October 25, 11

Page 32: MySQL Sandbox - A toolkit for productive 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

Tuesday, October 25, 11

Page 33: MySQL Sandbox - A toolkit for productive laziness

overview

MySQLserver

MySQLserver

Data DB1

DB2 DB3

Data DB1

DB2 DB3DATA DIRECTORY

PORT

SOCKET

Tuesday, October 25, 11

Page 34: MySQL Sandbox - A toolkit for productive laziness

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

Page 35: MySQL Sandbox - A toolkit for productive laziness

overview

MySQLserver

MySQLserver

SAME PORT or SOCKET?

DOES NOT START

/tmp/mysql.sock /tmp/mysql.sock

33063306

Tuesday, October 25, 11

Page 36: MySQL Sandbox - A toolkit for productive laziness

The hard way (1)

Tuesday, October 25, 11

Page 37: MySQL Sandbox - A toolkit for productive laziness

the hard way (2)

Tuesday, October 25, 11

Page 38: MySQL Sandbox - A toolkit for productive laziness

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

Page 39: MySQL Sandbox - A toolkit for productive laziness

The easier way$ make_sandbox 5.1.54

# Needs some preliminary work

Tuesday, October 25, 11

Page 40: MySQL Sandbox - A toolkit for productive laziness

The easiest way$ sb 5.1.54

# Needs the same preliminary work

Tuesday, October 25, 11

Page 41: MySQL Sandbox - A toolkit for productive laziness

MySQL Sandbox

MySQLserver

VERSION

$SANDBOX_HOME/msb_VERSION/dataData DB1

DB2 DB3

VERSION

/tmp/mysql_VERSION.sock

Tuesday, October 25, 11

Page 42: MySQL Sandbox - A toolkit for productive laziness

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

Page 43: MySQL Sandbox - A toolkit for productive laziness

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

Page 44: MySQL Sandbox - A toolkit for productive laziness

Single SandboxMySQLserver

customized scripts

startstop

restartstatusclear

send_killuse

Tuesday, October 25, 11

Page 45: MySQL Sandbox - A toolkit for productive laziness

Multiple SandboxMySQLserver

customized scripts

start_allstop_all

restart_allstatus_allclear_all

send_kill_all

use_all

ms1s2

n1n2n3

Tuesday, October 25, 11

Page 46: MySQL Sandbox - A toolkit for productive laziness

Where do you get it

•from CPANsudo cpan MySQL::Sandbox

•from launchpadhttp://launchpad.net/mysql-sandbox

Tuesday, October 25, 11

Page 47: MySQL Sandbox - A toolkit for productive laziness

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

Page 48: MySQL Sandbox - A toolkit for productive laziness

default architecture

$HOME

/sandboxes opt

mysql

$SANDBOX_HOME

$SANDBOX_BINARY

expandedtarballs

installed sandboxes

Tuesday, October 25, 11

Page 49: MySQL Sandbox - A toolkit for productive 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

node2Tuesday, October 25, 11

Page 50: MySQL Sandbox - A toolkit for productive laziness

Tuesday, October 25, 11

Page 51: MySQL Sandbox - A toolkit for productive laziness

creating a single sandbox

make_sandbox \ /path/to/mysql-X.X.XX-OS.tar.gz

Tuesday, October 25, 11

Page 52: MySQL Sandbox - A toolkit for productive laziness

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

Page 53: MySQL Sandbox - A toolkit for productive laziness

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

Page 54: MySQL Sandbox - A toolkit for productive 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

Tuesday, October 25, 11

Page 55: MySQL Sandbox - A toolkit for productive laziness

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

Page 56: MySQL Sandbox - A toolkit for productive laziness

starting a single sandbox

$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start

Tuesday, October 25, 11

Page 57: MySQL Sandbox - A toolkit for productive laziness

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

Page 58: MySQL Sandbox - A toolkit for productive laziness

creating a sandbox with custom port and directory

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

Tuesday, October 25, 11

Page 59: MySQL Sandbox - A toolkit for productive 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

Tuesday, October 25, 11

Page 60: MySQL Sandbox - A toolkit for productive laziness

create a replication sandbox

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

Tuesday, October 25, 11

Page 61: MySQL Sandbox - A toolkit for productive laziness

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

Page 62: MySQL Sandbox - A toolkit for productive laziness

changing port to an existing sandbox

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

Tuesday, October 25, 11

Page 63: MySQL Sandbox - A toolkit for productive laziness

installing the innodb plugin

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

Tuesday, October 25, 11

Page 64: MySQL Sandbox - A toolkit for productive 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

Tuesday, October 25, 11

Page 65: MySQL Sandbox - A toolkit for productive laziness

more recipes

$ perldoc MySQL::Sandbox::Recipes

Tuesday, October 25, 11

Page 66: MySQL Sandbox - A toolkit for productive laziness

MySQL Sandbox evolution

Tuesday, October 25, 11

Page 67: MySQL Sandbox - A toolkit for productive laziness

Tungsten Sandbox

Tuesday, October 25, 11

Page 68: MySQL Sandbox - A toolkit for productive laziness

base_dir

database1

database2

database3

replicator1

replicator2

replicator3

TSB

sandboxes

HOME

Tuesday, October 25, 11

Page 69: MySQL Sandbox - A toolkit for productive laziness

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

Page 70: MySQL Sandbox - A toolkit for productive laziness

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

Page 71: MySQL Sandbox - A toolkit for productive laziness

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

Page 72: MySQL Sandbox - A toolkit for productive laziness

Participate!

Tuesday, October 25, 11

Page 73: MySQL Sandbox - A toolkit for productive laziness

Participate!

Tuesday, October 25, 11

Page 74: MySQL Sandbox - A toolkit for productive 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!

Tuesday, October 25, 11