Testing mysql creatively in a sandbox

Post on 20-Aug-2015

967 views 2 download

Tags:

Transcript of Testing mysql creatively in a sandbox

Testing MySQL Creatively in a sandboxGiuseppe 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.

1Tuesday, February 7, 12

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

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

Laziness

2Tuesday, February 7, 12

I have the ability

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

• I ADMIT IT: I AM LAZY

3Tuesday, February 7, 12

I have the ability

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

• I ADMIT IT: I AM LAZY

3Tuesday, February 7, 12

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

(*)

4Tuesday, February 7, 12

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

• Supports MySQL, Percona, MariaDB servers

• Installs IN SECONDS

http://mysqlsandbox.net

5Tuesday, February 7, 12

overview

MySQLserver

MySQLserver

Data DB1

DB2 DB3

Data DB1

DB2 DB3DATA DIRECTORY

PORT

SOCKET

6Tuesday, February 7, 12

overview

MySQLserver

MySQLserver

Data DB1

DB2 DB3

Data DB1

DB2 DB3

SAME DATA

DIRECTORY?

DATA CORRUPTION

/var/lib/mysql /var/lib/mysql

7Tuesday, February 7, 12

overview

MySQLserver

MySQLserver

SAME PORT or SOCKET?

DOES NOT START

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

33063306

8Tuesday, February 7, 12

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

9Tuesday, February 7, 12

The easier way$ make_sandbox 5.1.54

# Needs some preliminary work

10Tuesday, February 7, 12

The easiest way$ sb 5.1.54

# Needs the same preliminary work

11Tuesday, February 7, 12

MySQL Sandbox

MySQLserver

VERSION

$SANDBOX_HOME/msb_VERSION/dataData DB1

DB2 DB3

VERSION

/tmp/mysql_VERSION.sock

12Tuesday, February 7, 12

MySQL Sandbox

MySQLserver

5.1.54

$SANDBOX_HOME/msb_5_1_54/dataData DB1

DB2 DB3

5154

/tmp/mysql_5154.sock

13Tuesday, February 7, 12

MySQL Sandbox

MySQLserver

5.5.9

$SANDBOX_HOME/msb_5_5_09/dataData DB1

DB2 DB3

5509

/tmp/mysql_5509.sock

14Tuesday, February 7, 12

Single SandboxMySQLserver

customized scripts

startstop

restartstatusclear

send_killuse

15Tuesday, February 7, 12

Multiple SandboxMySQLserver

customized scripts

start_allstop_all

restart_allstatus_allclear_all

send_kill_all

use_all

ms1s2

n1n2n3

16Tuesday, February 7, 12

Where do you get it

•from CPAN$ sudo su -

# cpan MySQL::Sandbox

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

17Tuesday, February 7, 12

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

18Tuesday, February 7, 12

default architecture

$HOME

/sandboxes opt

mysql

$SANDBOX_HOME

$SANDBOX_BINARY

expandedtarballs

installed sandboxes

19Tuesday, February 7, 12

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

node220Tuesday, February 7, 12

21Tuesday, February 7, 12

creating a single sandbox

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

22Tuesday, February 7, 12

using a single sandbox

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

$ cd $SANDBOX_HOME/msb_X_X_XX$ ./use

23Tuesday, February 7, 12

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

24Tuesday, February 7, 12

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

25Tuesday, February 7, 12

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

26Tuesday, February 7, 12

starting a single sandbox

$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start

27Tuesday, February 7, 12

starting a single sandboxwith temporary options

$ cd $SANDBOX_HOME/msb_X_X_XX$ ./start --option=value

$ ./restart --option=value

$ ./start --key-buffer=20000000

28Tuesday, February 7, 12

creating a sandbox with custom port and directory

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

29Tuesday, February 7, 12

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

30Tuesday, February 7, 12

create a replication sandbox

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

31Tuesday, February 7, 12

changing port to an existing sandbox

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

32Tuesday, February 7, 12

more recipes

$ perldoc MySQL::Sandbox::Recipes

33Tuesday, February 7, 12

MySQL Sandbox evolution

34Tuesday, February 7, 12

More flexible

• make_sandbox

• --high_performance

• --master (creates a standalone master)

• --slaveof (makes a quick slave of an existing server, even of different versions)

35Tuesday, February 7, 12

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'

36Tuesday, February 7, 12

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'

37Tuesday, February 7, 12

Tungsten Sandbox

38Tuesday, February 7, 12

base_dir

database1

database2

database3

replicator1

replicator2

replicator3

TSB

sandboxes

HOME

39Tuesday, February 7, 12

tungsten sandbox help Tungsten Tools, version 2.0.07 Tungsten Sandbox - Cluster builder (C) 2011 Giuseppe Maxia, Continuent, IncSyntax: /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

40Tuesday, February 7, 12

tungsten sandbox$ tungsten-sandbox -m 5.5.10 \ --topology=master-slave

$ tungsten-sandbox -m 5.1.60 \ --topology=star \ --nodes=5 --hub=2

$ tungsten-sandbox -m 5.5.18 \ --topology=direct \ --nodes=2

$ tungsten-sandbox -m 5.1.60 \ --topology=all-masters \ --nodes=8

41Tuesday, February 7, 12

tungsten sandboxls ~/tsb2clear_tsandbox db2 db_clear_all db_send_kill_all db_status_all db_use_all n1 n3 restart_tsandbox test_topology tungsten_sandbox.infodb1 db3 db_restart_all db_start_all db_stop_all erase_tsandbox n2 replicator_all services_all trepctl_all

42Tuesday, February 7, 12

Participate!

43Tuesday, February 7, 12

Participate!

44Tuesday, February 7, 12

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!

45Tuesday, February 7, 12