什么是mysql sandbox?

mysql sandbox 是一个用per语言写的一套mysql部署工具

http://sourceforge.net/projects/mysql-sandbox/

通过mysql sandbix可以快速部署多种mysql使用环境包括:

单实例mysql

多实例mysql

单机mysql replication环境

mysqlsandbox主要用于测试环境的快速搭


安装流程:

下载mysql snadbox 安装包, 并编译,安装。

创建一个系统普通用户

下载mysql预编译二进制包版本压缩包

根据需要,使用mysql sandbox 命令快速部署mysql 环境


as root install 

tar xvf MySQL-Sandbox-3.0.43.tar -C  /usr/local/

cd /usr/local/MySQL-Sandbox-3.0.43

perl Makefile.PL

make 

make test

make install 


 

[root@host1 bin]# cd /home/

[root@host1 home]# ls

[root@host1 home]# useradd tube 

[root@host1 home]# id tube

uid=500(tube) gid=501(tube) groups=501(tube)

[root@host1 home]# cp /root/mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz  tube/

[root@host1 home]# cd tube/

[root@host1 tube]# chown tube. mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz 

[root@host1 tube]# ll

total 297952

-rw-r--r--. 1 tube tube 305102088 Jan 21 04:17 mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz

[root@host1 tube]# 

[root@host1 tube]# su - tube 

[tube@host1 ~]$ make_

make_multiple_custom_sandbox  make_replication_sandbox      make_sandbox_from_installed   

make_multiple_sandbox         make_sandbox                  make_sandbox_from_source      

[tube@host1 ~]$ make_multiple_sandbox mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz    --默认是三个节点,3个实例

installing node 1

installing node 2

installing node 3

group directory installed in $HOME/sandboxes/multi_msb_mysql-5_6_17


之后会自动启动

[tube@host1 multi_msb_mysql-5_6_17]$ ps -ef | grep mysql

tube     12071     1  0 04:23 pts/3    00:00:00 /bin/sh /home/tube/5.6.17/bin/mysqld_safe --defaults-file=/home/tube/sandboxes/multi_msb_mysql-


5_6_17/node1/my.sandbox.cnf

tube     12276 12071  0 04:23 pts/3    00:00:01 /home/tube/5.6.17/bin/mysqld --defaults-file=/home/tube/sandboxes/multi_msb_mysql-


5_6_17/node1/my.sandbox.cnf --basedir=/home/tube/5.6.17 --datadir=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node1/data --plugin-


dir=/home/tube/5.6.17/lib/plugin --log-error=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node1/data/msandbox.err --pid-


file=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node1/data/mysql_sandbox14318.pid --socket=/tmp/mysql_sandbox14318.sock --port=14318

tube     12369     1  0 04:23 pts/3    00:00:00 /bin/sh /home/tube/5.6.17/bin/mysqld_safe --defaults-file=/home/tube/sandboxes/multi_msb_mysql-


5_6_17/node2/my.sandbox.cnf

tube     12574 12369  0 04:23 pts/3    00:00:01 /home/tube/5.6.17/bin/mysqld --defaults-file=/home/tube/sandboxes/multi_msb_mysql-


5_6_17/node2/my.sandbox.cnf --basedir=/home/tube/5.6.17 --datadir=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node2/data --plugin-


dir=/home/tube/5.6.17/lib/plugin --log-error=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node2/data/msandbox.err --pid-


file=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node2/data/mysql_sandbox14319.pid --socket=/tmp/mysql_sandbox14319.sock --port=14319

tube     12666     1  0 04:24 pts/3    00:00:00 /bin/sh /home/tube/5.6.17/bin/mysqld_safe --defaults-file=/home/tube/sandboxes/multi_msb_mysql-


5_6_17/node3/my.sandbox.cnf

tube     12872 12666  0 04:24 pts/3    00:00:01 /home/tube/5.6.17/bin/mysqld --defaults-file=/home/tube/sandboxes/multi_msb_mysql-


5_6_17/node3/my.sandbox.cnf --basedir=/home/tube/5.6.17 --datadir=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node3/data --plugin-


dir=/home/tube/5.6.17/lib/plugin --log-error=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node3/data/msandbox.err --pid-


file=/home/tube/sandboxes/multi_msb_mysql-5_6_17/node3/data/mysql_sandbox14320.pid --socket=/tmp/mysql_sandbox14320.sock --port=14320

tube     12959 11969  0 04:29 pts/3    00:00:00 grep mysql



单机多实例部署完毕





如果部署replication  ??


[tube@host1 ~]$ make_replication_sandbox  /home/tube/5.6.17 

 installing and starting master

installing slave 1

installing slave 2

starting slave 1

...... sandbox server started

starting slave 2

...... sandbox server started

initializing slave 1

initializing slave 2

replication directory installed in $HOME/sandboxes/rsandbox_5_6_17



sandbox  单实例命令


start              启动服务,在数据文件目录中创建一个.pid文件。 在/tmp目录中创建一个socket文件。

stop               关闭服务,删除.pid 删除socket      

clear              关闭服务,删除所有数据文件 

use                启动mysql 客户端  根据my_sandbox.cnf配置登陆mysql,默认用户名、密码msandbox/msandbox 。默认root密码:msandbox 


sandbox 多实例命令


start_all  启动所有实例

stop_all   关闭所有实例

clear_all  清除所有实例


replication sandbox命令

m

登录到master

s1

登录到第一台slave

s2

登陆带第二台salve