The document discusses dbdeployer, a command line tool for deploying and testing MySQL database topologies. It can deploy single or multiple MySQL instances, as well as complex topologies like replication, group replication, and multi-source replication with a single command. Dbdeployer aims to make deploying and testing databases fast and easy by avoiding repetitive manual tasks. It has features for upgrading and importing existing databases.
Human Factors of XR: Using Human Factors to Design XR Systems
Test like a_boss
1. Test like a boss:
Deploy and test complex
topologies with a single command
Giuseppe Maxia
dbdeployer
2. Who's this guy?
About me
‣ Giuseppe Maxia, a.k.a. "The Data Charmer"
‣ Software Explorer at VMware
‣ Several decades development and DB experience
‣ Long timer MySQL community member.
‣ Blog: http://datacharmer.blogspot.com
‣ Twitter: @datacharmer
!2
5. dbdeployer
• Command line tool to deploy MySQL in a sandbox
• No dependencies (single binary per O.S., written in go)
• Interface similar to git, docker
• Fast!
• Runs single database, replication, group replication,
multiple deployments, multi-source replication.
• Integrated help
• Easy to extend.
https://dbdeployer.org
9. Basic dbdeployer principle
•LAZINESS!
•i.e. try avoiding repeated tasks, or
doing difficult things manually.
•Whenever a repeated task
becomes annoying, a new
dbdeployer feature comes out.
14. MySQL upgrade
• Will deploy MySQL 5.5 and 5.6
• and upgrade 5.5 to 5.6
• Then deploy MySQL 5.7
15. MySQL upgrade
• Will deploy MySQL 5.5 and 5.6
• and upgrade 5.5 to 5.6
• Then deploy MySQL 5.7
• and upgrade from 5.6 to 5.7
16. MySQL upgrade
• Will deploy MySQL 5.5 and 5.6
• and upgrade 5.5 to 5.6
• Then deploy MySQL 5.7
• and upgrade from 5.6 to 5.7
• Then deploy MySQL 8.0
17. MySQL upgrade
• Will deploy MySQL 5.5 and 5.6
• and upgrade 5.5 to 5.6
• Then deploy MySQL 5.7
• and upgrade from 5.6 to 5.7
• Then deploy MySQL 8.0
• and upgrade from 5.7 to 8.0
18. MySQL upgrade
• Will deploy MySQL 5.5 and 5.6
• and upgrade 5.5 to 5.6
• Then deploy MySQL 5.7
• and upgrade from 5.6 to 5.7
• Then deploy MySQL 8.0
• and upgrade from 5.7 to 8.0
ALL IN LESS THAN
ONE MINUTE!
20. WHY have I used it?
• Support to customers using different versions
• Consulting
• Rapid prototyping
• Testing of new versions
• Reporting bugs
• Avoid using a VM
21. WHY have I used it?
• Support to customers using different versions
• Consulting
• Rapid prototyping
• Testing of new versions
• Reporting bugs
• Avoid using a VM
Do you have a different
reason?
Let me know via Twitter
@datacharmer
23. Physical server deployments
• Best performance
• Highest isolation
• Low scalability
bare metal
operating system
libraries/applications
service service service service service service
Sandboxes, VMs, containers (1)
24. Virtual machines
• High scalability
• Good isolation
• Low performance
bare metal
host operating system
hypervisor
virtual machine
service
guest operating system
libraries/applications
virtual machine
service
guest operating system
libraries/applications
virtual machine
service
guest operating system
libraries/applications
Sandboxes, VMs, containers (2)
25. Docker containers
• High scalability
• High performance
• Minimal isolation
bare metal
host operating system
Docker engine
container
service
library
library
container
service
library
library
container
service
library
container
service
library
library
library
library
Sandboxes, VMs, containers (3)
26. Sandboxes
• Best performance
• High scalability
• Low isolation
bare metal
operating system
libraries/applications
service service service service service service
Sandboxes, VMs, containers (4)
28. What can it do? (1)
• Install a single MySQL sandbox of ANY VERSION
• Separated from any existing MySQL server
• Completely in user space
• Reasonably isolated
• Simple to use and administer
dbdeployer deploy single 8.0
29. What can it do? (2)
• Install a group of sandboxes
• Isolated from each other
• Without any relationship
• With binary logging active
dbdeployer deploy multiple 8.0
30. What can it do? (3)
• Install a master-slave replication cluster
• 1 master and 2 (or more) slaves
• Replication enabled
• Optional GTID
• Handy tools to run operations on all nodes at once
dbdeployer deploy replication 8.0
--topology=master-slave
31. What can it do? (4)
• Install a group replication cluster (MySQL 5.7 and 8.0)
• 3 (or more) nodes
• Single-primary or multi-primary
• Group replication configured and enabled
• Handy tools to run operations on all nodes at once
dbdeployer deploy replication 8.0
--topology=group
32. What can it do? (5)
• Install a multi-source replication cluster (MySQL 5.7-8.0)
• 3 (or more) nodes
• fan-in or all-masters topologies
• Handy tools to run operations on all nodes at once
dbdeployer deploy replication 8.0.17
--topology=fan-in # or all-masters
33. What can it do? (6)
• Install a single or multiple TiDB sandbox
dbdeployer deploy single tidb3.0.0
--client-from=5.7.25
dbdeployer deploy multiple tidb3.0.0
--client-from=5.7.25
34. What can it do? (7)
• Install a Percona XtraDB cluster (5.7, only Linux)
• 3 (or more) nodes
• Handy tools to run operations on all nodes at once
dbdeployer deploy replication pxc5.7
--topology=pxc
35. What can it do? (8)
• Install a MySQL Cluster (NDB 7.6 and 8.0)
• 3 (or more) nodes
• Handy tools to run operations on all nodes at once
dbdeployer deploy replication ndb7.6
--topology=ndb
36. What can it do? (9)
• Administer sandboxes
• List available binaries
• List installed sandboxes
• start, restart (with options), stop
• check status
• test
• delete
37. What can it do? (10)
• Customize sandboxes
• Customizable initialization and database start
• Provide templates for every script
• Allow on-the-fly and permanent template replacement
• Change most of the default values
• Make sandboxes permanent (= can't be deleted)
38. What can it do? (11)
• Find free ports automatically
• Test replication flow
• Expose MySQL 8 dictionary tables
• Use semi-sync replication
• Run SQL command before and after loading grants
• enable/disable X-protocol
39. What can it do? (12)
• List downloads for MacOS and Linux (dbdeployer 1.33.0)
• Download latest binaries directly
dbdeployer downloads list
40. What can it do? (12)
• List downloads for MacOS and Linux (dbdeployer 1.33.0)
• Download latest binaries directly
dbdeployer downloads list
dbdeployer downloads get mysql-5.7.26.tar.xz
41. What can it do? (12)
• List downloads for MacOS and Linux (dbdeployer 1.33.0)
• Download latest binaries directly
dbdeployer downloads list
dbdeployer downloads get mysql-5.7.26.tar.xz
dbdeployer downloads get-by-version 8.0
--newest --minimal
42. What can it do? (12)
• List downloads for MacOS and Linux (dbdeployer 1.33.0)
• Download latest binaries directly
dbdeployer downloads list
dbdeployer downloads get mysql-5.7.26.tar.xz
dbdeployer downloads get-by-version 8.0
--newest --minimal
dbdeployer downloads get-unpack
mysql-5.7.26.tar.xz
43. What can it do? (13)
• Import existing database servers into a sandbox
(dbdeployer 1.39.0)
• Use the imported sandbox with regular sandbox scripts
44. What can it do? (13)
• Import existing database servers into a sandbox
(dbdeployer 1.39.0)
• Use the imported sandbox with regular sandbox scripts
dbdeployer import single
192.168.0.164 3306
admin notMyPassword
47. Installation (1)
1. Go to https://github.com/datacharmer/dbdeployer
2. Find releases
3. Download the binary for your O.S.
4. Put it in a directory within your $PATH
5. Run it!
66. Using it
(the modern way)
$ dbdeployer downloads list
Available tarballs (2019-08-10)
name version flavor size
--------------------------------------------------- --------- ------------- -------
tidb-master-darwin-amd64.tar.gz 3.0.0 tidb 26 MB
mysql-5.7.26-macos10.14-x86_64.tar.gz 5.7.26 mysql 337 MB
mysql-8.0.16-macos10.14-x86_64.tar.gz 8.0.16 mysql 153 MB
mysql-8.0.15-macos10.14-x86_64.tar.gz 8.0.15 mysql 139 MB
mysql-5.7.25-macos10.14-x86_64.tar.gz 5.7.25 mysql 337 MB
mysql-5.6.41-macos10.13-x86_64.tar.gz 5.6.41 mysql 176 MB
mysql-5.5.53-osx10.9-x86_64.tar.gz 5.5.53 mysql 114 MB
mysql-5.1.73-osx10.6-x86_64.tar.gz 5.1.73 mysql 82 MB
mysql-5.0.96-osx10.5-x86_64.tar.gz 5.0.96 mysql 61 MB
mysql-cluster-8.0.16-dmr-macos10.14-x86_64.tar.gz 8.0.16 ndb 252 MB
mysql-8.0.17-macos10.14-x86_64.tar.gz 8.0.17 mysql 155 MB
mysql-5.7.27-macos10.14-x86_64.tar.gz 5.7.27 mysql 337 MB
mysql-cluster-gpl-7.6.10-macos10.14-x86_64.tar.gz 7.6.10 ndb 482 MB
mysql-cluster-8.0.17-rc-macos10.14-x86_64.tar.gz 8.0.17 ndb 255 MB
mysql-cluster-gpl-7.6.11-macos10.14-x86_64.tar.gz 7.6.11 ndb 482 MB
mysql-shell-8.0.17-macos10.14-x86-64bit.tar.gz 8.0.17 mysql-shell 17 MB
(1a)
67. Using it
(the modern way)
$ dbdeployer downloads list
Available tarballs (2019-08-10)
name version flavor size minimal
-------------------------------------------------------- --------- ------------- -------- ---------
tidb-master-linux-amd64.tar.gz 3.0.0 tidb 26 MB
mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz 8.0.16 mysql 461 MB
mysql-8.0.16-linux-x86_64-minimal.tar.xz 8.0.16 mysql 44 MB Y
mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz 5.7.27 mysql 645 MB
mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz 8.0.17 mysql 480 MB
mysql-8.0.17-linux-x86_64-minimal.tar.xz 8.0.17 mysql 45 MB Y
mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 5.7.26 mysql 645 MB
mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz 5.6.44 mysql 329 MB
mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz 5.5.62 mysql 199 MB
mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz 8.0.15 mysql 376 MB
mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz 8.0.13 mysql 394 MB
mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz 5.7.25 mysql 645 MB
mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz 5.6.43 mysql 329 MB
mysql-5.5.61-linux-glibc2.12-x86_64.tar.gz 5.5.61 mysql 199 MB
mysql-5.1.73-linux-x86_64-glibc23.tar.gz 5.1.73 mysql 134 MB
mysql-5.0.96.tar.xz 5.0.96 mysql 5.5 MB Y
mysql-5.1.72.tar.xz 5.1.72 mysql 10 MB Y
mysql-5.5.61.tar.xz 5.5.61 mysql 6.6 MB Y
mysql-5.5.62.tar.xz 5.5.62 mysql 6.6 MB Y
mysql-5.6.43.tar.xz 5.6.43 mysql 9.0 MB Y
mysql-5.6.44.tar.xz 5.6.44 mysql 9.1 MB Y
mysql-5.7.25.tar.xz 5.7.25 mysql 23 MB Y
mysql-5.7.26.tar.xz 5.7.26 mysql 23 MB Y
mysql-5.0.96-linux-x86_64-glibc23.tar.gz 5.0.96 mysql 127 MB
mysql-4.1.22.tar.xz 4.1.22 mysql 4.6 MB Y
mysql-cluster-gpl-7.6.10-linux-glibc2.12-x86_64.tar.gz 7.6.10 ndb 916 MB
mysql-cluster-8.0.16-dmr-linux-glibc2.12-x86_64.tar.gz 8.0.16 ndb 1.1 GB
mysql-cluster-gpl-7.6.11-linux-glibc2.12-x86_64.tar.gz 7.6.11 ndb 916 MB
mysql-cluster-8.0.17-rc-linux-glibc2.12-x86_64.tar.gz 8.0.17 ndb 1.1 GB
mysql-shell-8.0.17-linux-glibc2.12-x86-64bit.tar.gz 8.0.17 mysql-shell 30 MB
(1b)
68. Using it
(the modern way)
$ dbdeployer downloads show
mysql-8.0.17-linux-x86_64-minimal.tar.xz
Name: mysql-8.0.17-linux-x86_64-
minimal.tar.xz
Short version: 8.0
Version: 8.0.17
Flavor: mysql
OS: Linux
URL: https://dev.mysql.com/get/
Downloads/MySQL-8.0/mysql-8.0.17-linux-x86_64-
minimal.tar.xz
Checksum: MD5:
26e807f0140472fcc40166a67a775c7d
Size: 45 MB
(1c)
69. Using it
(the modern way)
$ dbdeployer downloads get
mysql-8.0.17-linux-x86_64-minimal.tar.xz
(1d)
72. Principles (revised)
get a MySQL
binary tarball
1
dbdeployer downloads get
mysql-5.7.27-yourOS.tar.gz
dbdeployer unpack2
$HOME/opt/mysql/5.7.27
73. Principles (revised)
get a MySQL
binary tarball
1
dbdeployer downloads get
mysql-5.7.27-yourOS.tar.gz
dbdeployer unpack2
$HOME/opt/mysql/5.7.27
dbdeployer deploy single3
$HOME/sandboxes/msb_5_7_27
74. Principles (revised)
get a MySQL
binary tarball
1
dbdeployer downloads get
mysql-5.7.27-yourOS.tar.gz
dbdeployer unpack2
$HOME/opt/mysql/5.7.27
dbdeployer deploy single3
$HOME/sandboxes/msb_5_7_27
dbdeployer deploy multiple3
$HOME/sandboxes/multi_msb_5_7_27
84. init_db
• Initialises the server.
• Useful to see what is being done at startup
# sample:
$HOME/opt/mysql/8.0.17/bin/mysqld
--no-defaults
--user=gmax
--basedir=$BASEDIR
--datadir=$DATADIR
--tmpdir=$SBDIR/tmp
--initialize-insecure
85. use / use_admin
• Runs the mysql client with the right options
• use_admin exists if you used --enable-admin-address
# sample:
./use -e 'select @@port'
86. start/restart
• starts or restarts the server with optional parameters
• the optional parameters are only valid until the server stops
# sample:
./restart --max-allowed-packet=209715200
./stop
./start --max-connections=650
87. status
• Show the status of the sandbox
• "on" = running, "off" = not running
# sample:
$ ./status
msb_8_0_17 on
./stop
./status
msb_8_0_17 off
88. add_option
• restarts the server with a permanent new option
•
# sample:
# NOTE: no '--'
./add_option max-allowed-packet=209715200
89. stop/send_kill
• Stops the server cleanly
• If the command fails, send_kill will attempt a stronger method
# sample:
./stop
./start
./send_kill
Attempting normal termination --- kill -15 70070
90. clear
• Stops the server and REMOVES ALL DATA
• WARNING: cannot be undone
# sample:
./clear
./status
msb_8_0_17 off
91. my
• prefix for all "my*" tools
• It adds automatically all options
# sample:
# NOTE: space between "my" and "sqldump"
./my sqldump database_name > file_name
# runs
# mysqldump --defaults-file=$PWD/my.sandbox.cnf
database_name
92. show_log
• shows the error log
# sample:
./show_log
###################### WARNING ############################
# You are not using a pager.
# The output of this script can be quite large.
# Please pipe this script with a pager, such as 'less' or
'vim -'
# Choose one of the following:
# * simply RETURN to continue without a pager
# * 'q' to exit
# * enter the name of the pager to use
q
./show_log | less
94. replicate_from
• replicates from another sandbox
• both sandboxes need to be replication ready
# sample:
$ dbdeployer sandboxes
msb_8_0_17_1 : single 8.0.17 [8017 18017 ]
msb_8_0_17_2 : single 8.0.17 [8018 18018 ]
$ cd ~/sandboxes/msb_8_0_17_1
$ ./replicate_from msb_8_0_17_2
or
$ ./replicate_from msb_8_0_17_2 clone
95. clone_from
• clones from another sandbox
• both sandboxes need to be clone ready (8.0.17+)
# sample:
$ dbdeployer sandboxes
msb_8_0_17_1 : single 8.0.17 [8017 18017 ]
msb_8_0_17_2 : single 8.0.17 [8018 18018 ]
$ cd ~/sandboxes/msb_8_0_17_1
$ ./clone_from msb_8_0_17_2
96. Single sandbox data
1. my.sandbox.cnf
2. grants.mysql
3. metadata
4. connection.conf
5. connection.json
6. connection.sql
7. sbdescription.json
1. options file
2. grants for all sandbox users
3. metadata
4. connection data
5. connection data
6. connection commands
7. sandbox info
102. status_all, start_all, *_all
• same as corresponding single commands
• execute them on all nodes
# sample:
$ ./status_all
REPLICATION /Users/gmax/sandboxes/
rsandbox_8_0_17
master : master on - port 20718 (20718)
node1 : node1 on - port 20719 (20719)
node2 : node2 on - port 20720 (20720)
103. use_all, use_all_masters, use_all_slaves
• runs a query in all nodes or all masters or all slaves
•
# sample:
$ ./use_all 'select @@server_id'
# master
@@server_id
100
# server: 1
@@server_id
200
# server: 2
@@server_id
300
104. test_replication
• checks that replication is working
•
$ ./test_replication
# master log: mysql-bin.000001 - Position: 14700 - Rows: 20
# Testing slave #1
ok - slave #1 acknowledged reception of transactions from master
ok - slave #1 IO thread is running
ok - slave #1 SQL thread is running
ok - Table t1 found on slave #1
ok - Table t1 has 20 rows on #1
# Testing slave #2
ok - slave #2 acknowledged reception of transactions from master
ok - slave #2 IO thread is running
ok - slave #2 SQL thread is running
ok - Table t1 found on slave #2
ok - Table t1 has 20 rows on #2
# Tests : 10
# failed: 0 ( 0.0%)
# PASSED: 10 (100.0%)
# exit code: 0
114. docker for dbdeployer
datacharmer/mysql-sb-base empty container, with latest
dbdeployer and pre-requisites
for running MySQL
datacharmer/mysql-sb-full mysql-sb-base +
extracted tarballs for MySQL
4.1, 5.0, 5.1, 5.5, 5.6, 5.7, 8.0
115. docker usage (1a)
# in the host OS
$ docker run -ti
-v $PWD:/workdir
datacharmer/mysql-sb-base bash
124. Importing sandboxes
• You can import an existing MySQL database into a sandbox
• The only requirement is that the database is accessible from
your machine
• Syntax:
dbdeployer import single IP port user password
• After importing, you can access the external database like any
other sandboxes
125. import example (1)
# Importing MySQL from a docker container
# with port 3306 redirected to host port 5000
$ dbdeployer import single
127.0.0.1 5000 public secret
detected: 8.0.17
# Using client version 8.0.17
Database installed in $HOME/sandboxes/
imp_msb_8_0_17
run 'dbdeployer usage single' for basic
instructions'
126. import example (2)
# You can replicate from the imported server
# into a regular sandbox
$ ~/sandboxes/msb_8_0_17/replicate_from
imp_msb_8_0_17
128. Many possibilities
192.168.0.15 - port 3306 192.168.0.21 - port 3306
sandbox sb1
imported
sandbox sb2
imported
sandbox sb3
Replicate from sb2
to sb1
(from 192.168.0.15
to 127.0.0.1)
129. Many possibilities
192.168.0.15 - port 3306 192.168.0.21 - port 3306
sandbox sb1
imported
sandbox sb2
imported
sandbox sb3
Replicate from sb2
to sb1
(from 192.168.0.15
to 127.0.0.1)
Replicate from sb3
to sb2
(from 192.168.0.21
to 192.168.0.15)