Testing mysql creatively in a sandbox

1,232 views
1,133 views

Published on

testing MySQL creatively in a sandbox

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,232
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Testing mysql creatively in a sandbox

  1. 1. Testing MySQLCreatively 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.Tuesday, February 7, 12 1
  2. 2. Laziness Laziness is a disinclination to activity or exertion despite having the ability to do so. http://en.wikipedia.org/wiki/LazinessTuesday, February 7, 12 2
  3. 3. I have the ability • but I dont feel inclined to do repetitive work • I ADMIT IT: I AM LAZYTuesday, February 7, 12 3
  4. 4. I have the ability • but I dont feel inclined to do repetitive work • I ADMIT IT: I AM LAZYTuesday, February 7, 12 3
  5. 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 peopleTuesday, February 7, 12 4
  6. 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 SECONDSTuesday, February 7, 12 5
  7. 7. overview MySQL MySQL server server Data DB1 Data DB1 DB2 DB3 DATA DIRECTORY DB2 DB3 PORT SOCKETTuesday, February 7, 12 6
  8. 8. overview MySQL MySQL server server Data DB1 SAME Data DB1 DB2 DB3 DATA DB2 DB3 DIRECTORY? /var/lib/mysql /var/lib/mysql DATA CORRUPTIONTuesday, February 7, 12 7
  9. 9. overview MySQL MySQL server server SAME PORT or SOCKET? 3306 3306 /tmp/mysql.sock /tmp/mysql.sock DOES NOT STARTTuesday, February 7, 12 8
  10. 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 alwaysTuesday, February 7, 12 9
  11. 11. The easier way $ make_sandbox 5.1.54 # Needs some preliminary workTuesday, February 7, 12 10
  12. 12. The easiest way $ sb 5.1.54 # Needs the same preliminary workTuesday, February 7, 12 11
  13. 13. MySQL Sandbox VERSION MySQL server Data DB1 DB2 DB3 $SANDBOX_HOME/msb_VERSION/data VERSION /tmp/mysql_VERSION.sockTuesday, February 7, 12 12
  14. 14. MySQL Sandbox 5.1.54 MySQL server Data DB1 DB2 DB3 $SANDBOX_HOME/msb_5_1_54/data 5154 /tmp/mysql_5154.sockTuesday, February 7, 12 13
  15. 15. MySQL Sandbox 5.5.9 MySQL server Data DB1 DB2 DB3 $SANDBOX_HOME/msb_5_5_09/data 5509 /tmp/mysql_5509.sockTuesday, February 7, 12 14
  16. 16. Single Sandbox MySQL customized scripts server start stop restart status clear send_kill useTuesday, February 7, 12 15
  17. 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_allTuesday, February 7, 12 16
  18. 18. Where do you get it •from CPAN $ sudo su - # cpan MySQL::Sandbox •from launchpad http://launchpad.net/mysql-sandboxTuesday, February 7, 12 17
  19. 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.54Tuesday, February 7, 12 18
  20. 20. default architecture $HOME /sandboxes opt expanded tarballs $SANDBOX_HOME mysql $SANDBOX_BINARY installed sandboxesTuesday, February 7, 12 19
  21. 21. default architecture $HOME /sandboxes opt msb_5_0_91 mysql msb_5_1_48 5.0.91 rsandbox_5_1_48 5.1.45 master 5.1.48 node1 5.5.4 node2Tuesday, February 7, 12 20
  22. 22. Tuesday, February 7, 12 21
  23. 23. creating a single sandbox make_sandbox /path/to/mysql-X.X.XX-OS.tar.gzTuesday, February 7, 12 22
  24. 24. using a single sandbox # after # make_sandbox # /path/to/mysql-X.X.XX-OS.tar.gz $ cd $SANDBOX_HOME/msb_X_X_XX $ ./useTuesday, February 7, 12 23
  25. 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.cnfTuesday, February 7, 12 24
  26. 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.34Tuesday, February 7, 12 25
  27. 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.gzTuesday, February 7, 12 26
  28. 28. starting a single sandbox $ cd $SANDBOX_HOME/msb_X_X_XX $ ./startTuesday, February 7, 12 27
  29. 29. starting a single sandbox with temporary options $ cd $SANDBOX_HOME/msb_X_X_XX $ ./start --option=value $ ./restart --option=value $ ./start --key-buffer=20000000Tuesday, February 7, 12 28
  30. 30. creating a sandbox with custom port and directory $ make_sandbox 5.1.34 -- --sandbox_port=7800 --sandbox_directory=mickeymouseTuesday, February 7, 12 29
  31. 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_aTuesday, February 7, 12 30
  32. 32. create a replication sandbox $ make_replication_sandbox path/to/mysql-5.1.34-osx10.5-x86.tar.gzTuesday, February 7, 12 31
  33. 33. changing port to an existing sandbox $ sbtool -o port -s /path/to/source/sandbox --new_port=XXXXTuesday, February 7, 12 32
  34. 34. more recipes $ perldoc MySQL::Sandbox::RecipesTuesday, February 7, 12 33
  35. 35. MySQL Sandbox evolutionTuesday, February 7, 12 34
  36. 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. 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=5157Tuesday, February 7, 12 36
  38. 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=optionsTuesday, February 7, 12 37
  39. 39. Tungsten SandboxTuesday, February 7, 12 38
  40. 40. replicator 1 replicator TSB 2 replicator 3 database HOME 1 database sandboxes base_dir 2 database 3Tuesday, February 7, 12 39
  41. 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 helpTuesday, February 7, 12 40
  42. 42. 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=8Tuesday, February 7, 12 41
  43. 43. tungsten sandbox ls ~/tsb2 clear_tsandbox db2 db_clear_all db_send_kill_all db_status_all db_use_all n1 n3 restart_tsandbox test_topology tungsten_sandbox.info db1 db3 db_restart_all db_start_all db_stop_all erase_tsandbox n2 replicator_all services_all trepctl_allTuesday, February 7, 12 42
  44. 44. Participate!Tuesday, February 7, 12 43
  45. 45. Participate!Tuesday, February 7, 12 44
  46. 46. THANKS Lets 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

×