nihaogirl 发表于 2018-10-3 07:35:42

mysql-sandbox

  什么是mysqlsandbox
  一群海豚在属于自己的海滩上自由的玩耍,尽管只是一个方盒的大小,但是设备一样的齐全,同样可以玩的很开心,这就是我今天要说的——MySQL Sandbox2.0,3.0也将要推出。
  MySQL   Sandbox是一个非常简单快捷部署MySQL技术的一个工具套件,它可以让你在同一台机器上,更加快速的无干扰的去达到你的最终目的,比如,作为软件 测试人员只是要测试软件系统的良好性不需要在mysql的安装上纠缠过多,不需要对MySQL数据库有太多的经验;有的时候我们只是对新版本的一些特性感 兴趣,尽可能快速结束安装部署,而是重点地去体验它的一些特性;可以使用sandbox最短时间部署我们需要的数据库应用架构 (ReplicationCluster),以配合我们的现有的应用系统进行性能测试。
  MySQL Sandbox 快速,是用秒来衡量的。下面我们就来感受一下sandbox给我们的F1般的速度,你可以在每次安装前使用time命令统计出real/user/sys三项的使用时间。
  安装mysqlsandbox
  下载MySQL-Sandbox-3.0.25.tar.gz,
  下载mysql-5.x.xx-linux-i686-glibc23.tar.gz
  解压mysqlsandbox
  


[*]tar -xf MySQL-Sandbox-3.0.25.tar.gz -C /mnt
  

  安装简单的几个步骤
  


[*]perl Makefile.PL
[*]
[*]make
[*]
[*]make test
[*]
[*]make install
  

  开始快速部署mysql
  


[*]make_sandbox mysql-5.1.42-linux-i686-icc-glibc23.tar.gz
  

  到这里可能会有报错
  用export设置变量使ROOT用户可用
  export SANDBOX_AS_ROOT=1
  最好的做法是写到root用户的 .bash_prefile下
  


[*]echo >> export SANDBOX_AS_ROOT=1 .bash_profile
  

  然后继续执行make_sandbox
  


[*]make_sandbox mysql-5.1.42-linux-i686-icc-glibc23.tar.gz
  

  
Use of uninitialized value in concatenation (.) or string at /usr/bin/make_sandbox line 111.
  
unpacking /mnt/mysql-5.1.42-linux-i686-icc-glibc23.tar.gz
  
Executing low_level_make_sandbox --basedir=/mnt/5.1.42 \
  
      --sandbox_directory=msb_5_1_42 \
  
      --install_version=5.1 \
  
      --sandbox_port=5142 \
  
      --no_ver_after_name \
  
      --my_clause=log-error=msandbox.err
  
    The MySQL Sandbox,version 3.0.25
  
    (C) 2006-2012 Giuseppe Maxia
  
installing with the following parameters:
  
upper_directory                = /root/sandboxes
  
sandbox_directory            = msb_5_1_42
  
sandbox_port                   = 5142
  
check_port                     =
  
no_check_port                  =
  
datadir_from                   = script
  
install_version                = 5.1
  
basedir                        = /mnt/5.1.42
  
tmpdir                         =
  
my_file                        =
  
operating_system_user          = root
  
db_user                        = msandbox
  
remote_access                  = 127.%
  
ro_user                        = msandbox_ro
  
rw_user                        = msandbox_rw
  
repl_user                      = rsandbox
  
db_password                  = msandbox
  
repl_password                  = rsandbox
  
my_clause                      = log-error=msandbox.err
  
master                         =
  
slaveof                        =
  
high_performance               =
  
prompt_prefix                  = mysql
  
prompt_body                  =[\h] {\u} (\d) >
  
force                        =
  
no_ver_after_name            = 1
  
verbose                        =
  
load_grants                  = 1
  
no_load_grants               =
  
no_run                         =
  
no_show                        =
  
                      y
  
loading   grants
  
. sandbox serverstarted
  
Your sandbox server was installed in $HOME/sandboxes/msb_5_1_42
  安装完成后会提示告知你安装在什么路径
  运行一个mysql
  # cd /root/sandboxes/msb_5_1_42/
  
# ls
  
change_pathsdata          msb             proxy_startstart   tmp
  
change_portsgrants.mysqlmy            restart      statususe
  
clear         load_grants   my.sandbox.cnfsend_kill    stop    USING
  
# ./use
  
Welcome to the MySQL monitor.Commands end with ; or \g.

  
Your MySQL connection>  
Server version: 5.1.42 MySQL Community Server (GPL)
  

  
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  

  
mysql {msandbox} ((none)) >
  
提示进入成功!
  


[*]./stop (停止数据库服务)
[*]
[*]./start (打开数据库服务)
  

  mysqlsandbox部署mysql-replication
  


[*]# make_replication_sandbox /mnt/mysql-5.1.42-linux-i686-icc-glibc23.tar.gz
[*]installing and starting master
[*]Use of uninitialized value in concatenation (.) or string at /usr/bin/make_sandbox line 111.
[*]installing slave 1
[*]Use of uninitialized value in concatenation (.) or string at /usr/bin/make_sandbox line 111.
[*]installing slave 2
[*]Use of uninitialized value in concatenation (.) or string at /usr/bin/make_sandbox line 111.
[*]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_mysql-5_1_42
[*]#
  

  在master上添加一个数据库haha
  


[*]./m -e 'create database haha'
  

  在slave1和slave2上查看是否有数据库haha
  


[*]# ./s2 -e 'show databases'
[*]+--------------------+
[*]| Database         |
[*]+--------------------+
[*]| information_schema |
[*]| haha               |
[*]| mysql            |
[*]| test               |
[*]+--------------------+
[*]# ./s1 -e 'show databases'  +--------------------+
  | Database         |
  +--------------------+
  | information_schema |
  | haha               |
  | mysql            |
  | test               |
  +--------------------+
  

  ./stop_all 关闭所有节点
  


[*]# ./stop_all
[*]executing "stop" on slave 1
[*]executing "stop" on slave 2
[*]executing "stop" on master
[*]#
  



页: [1]
查看完整版本: mysql-sandbox