Periodically (and sometimes quite often) there is a need for test or other purposes, to raise a couple of mysql servers, or with replication, for rolling back or debugging a process.
Automating this particular movement often makes no sense, since it is not as often necessary as you would like.
In Ineta, such a ready-made script was found. It is called
myslqsandbox - muscular sandbox. Works with MySQL versions from 3.23 to 6.0. Distributed under the GPL license.
The meaning is simple.
1. Downloading MySQL-Sandbox-3.0.17.tar.gz and unzip it and install
tar -zxvf MySQL-Sandbox-3.0.17.tar.gz
cd MySQL-Sandbox-3.0.17
tar -zxvf MySQL-Sandbox-3.0.17.tar.gz
cd MySQL-Sandbox-3.0.17
If you are root, then
export SANDBOX_AS_ROOT=1
perl Makefile.PL
make
make test
make install
If a regular / unusual mortal user, then
export PATH=$HOME/usr/local/bin:$PATH
export PERL5LIB=$HOME/usr/local/lib/perl5/site_perl/5.8.8
perl Makefile.PL PREFIX=$HOME/usr/local
make
make test
make install
At the same time, remember that depending on which Linux distribution you use, PERL5LIB may differ.
')
Now we have 2 options.
Option number 1.
If we already have mysql installed, then we can use the command and create a local sandbox.
make_sandbox_from_installed XXXX
where
XXXX is the version installed by mysql.
Option number 2.
We swing MySQL- <something-there-suitable> .tar.gz and with it we do a sandbox.
cd ~
wget 127.0.0.1/mysql-5.5.15-linux2.6-x86_64.tar.gz
make_sandbox mysql-5.5.15-linux2.6-x86_64.tar.gz
Your sandbox
~/msb_X_X_XX
is ready to use.
#netstat -lna
unix 2 [ ACC ] STREAM LISTENING 68883 /tmp/mysql_sandbox5515.sock
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
Everything you need (configs, commands) is located inside your home directory, and is cleaned by simple deletion.
You can use more interesting commands "sandbox". For example command
make_replication_sandbox ~/mysql-5.5.15-linux2.6-x86_64.tar.gz
creates a new instance from one master and two slave bases.
make_replication_sandbox --master_master ~/mysql-5.5.15-linux2.6-x86_64.tar.gz
creates master replica with two servers.
make_replication_sandbox --circular=4 ~/mysql-5.5.15-linux2.6-x86_64.tar.gz
creation of “circular” replication with 3 slave servers (available for mysql since version 5.1)
After each operation, the finished instances automatically start and are ready to work, sockets / ports are listened to. When creating a sandbox, 2 users are automatically created.
+ ----------------- + ------------- + ----------------- -------------- +
| user name | password | privileges |
+ ----------------- + ------------- + ----------------- -------------- +
| root @ localhost | msandbox | all on *. * with grant option |
| msandbox @% | msandbox | all on *. * |
+ ----------------- + ------------- + ----------------- -------------- +
This article is an attempt to share with the public the very fact of having such an amazing tool in its convenience.
Ps. In the future, I am ready to continue the description of this tool, since this description is only an introductory part.
Continued.