1.安装cpan
yum -y install cpan
2.安装依赖包
yum install perl-Test-Simple -y
3.安装MySQL sendbox
cpan MySQL::Sandbox
4.设置环境变量,将实例安装在这里
echo 'export SANDBOX_AS_ROOT=1' >> /root/.bash_profile
source /root/.bash_profile
5.准备安装包
[
root@10-186-24-106 mysql5.7]# ls
mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
6.创建实例
[root@10-186-24-106 sandboxes]# make_sandbox --help
The MySQL Sandbox, version 3.1.08
(C) 2006-2016 Giuseppe Maxia
usage: ./make_sandbox version [options] {VERSION|tarball_full_name} -- [more options]
--export_binaries exports the new binary to /opt/mysql
--add_prefix=NAME add given prefix to renamed tarball directory
make_sandbox mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
unpacking /yyh/mysql5.7/mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
Executing low_level_make_sandbox --basedir=/yyh/mysql5.7/5.7.11 \
--sandbox_directory=msb_5_7_11 \
--install_version=5.7 \
--sandbox_port=5711 \
--no_ver_after_name \
--check_port \
--my_clause=log-error=msandbox.err
The MySQL Sandbox, version 3.1.08
(C) 2006-2016 Giuseppe Maxia
Installing with the following parameters:
upper_directory = /root/sandboxes
sandbox_directory = msb_5_7_11_b
sandbox_port = 5714
check_port = 1
no_check_port =
datadir_from = script
install_version = 5.7
basedir = /yyh/mysql5.7/5.7.11
tmpdir =
my_file =
operating_system_user = root
db_user = msandbox
remote_access = 127.%
bind_address = 127.0.0.1
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 =
gtid =
pre_start_exec =
pre_grants_exec =
post_grants_exec =
pre_grants_sql =
post_grants_sql =
pre_grants_file =
post_grants_file =
load_plugin =
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 =
keep_uuid =
history_dir =
do you agree? ([Y],n) y
# Starting server
......... sandbox server started
# Loading grants
Your sandbox server was installed in $HOME/sandboxes/msb_5_7_11_b
7.文件位置
[
root@10-186-24-106 sandboxes]# ls
clear_all msb_5_7_11_a plugin.conf sandbox_action start_all stop_all use_all
msb_5_7_11 msb_5_7_11_b restart_all send_kill_all status_all test_replication
[
root@10-186-24-106 sandboxes]# ls msb_5_7_11
add_option clear default_connection.json json_in_db my mysqlsh restart show_relaylog stop USING
change_paths connection.json grants_5_7_6.mysql load_grants mycli proxy_start send_kill start tmp
change_ports data grants.mysql msb
my.sandbox.cnf(模板) README show_binlog status use
[
root@10-186-24-106 sandboxes]# ls msb_5_7_11_b/
add_option clear default_connection.json json_in_db my mysqlsh restart show_relaylog stop USING
change_paths connection.json grants_5_7_6.mysql load_grants mycli proxy_start send_kill start tmp
change_ports data grants.mysql msb
my.sandbox.cnf(本实例配置) README show_binlog status use
8.部署多个实例
make_multiple_sandbox mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
增加--how_many_nodes=number 指定部署number个实例
9.各种脚本
Simple administrative tasks can be performed using:
./start [options] : starts the server //启动实例
./restart [options] : restarts the server //重启实例
./stop : stops the server //停止实例
./status : tells if the server is running //实例状态
./clear : stops the server and removes all contents (WARNING!: dangerous)
//停止并删除所有内容(初始化)
./send_kill : stops an unresponsive server //停止未响应的实例
./my sqldump : calls mysqldump (notice the space after './my') //调用 dump、admin、binlog
./my sqladmin : calls mysqladmin (notice the space after './my')
./my sqlbinlog : calls mysqlbinlog (notice the space after './my')
./msb {start restart stop status} : all-purpose start/stop/status/restart command
//通用命令,控制所有实例
10.各种命令
make_sandbox : 最简单创建sandbox
low_level_make_sandbox : 创建单个sandbox,微调选项但不直接使用
make_replication_sandbox :创建master-slave架构
make_multiple_sandbox : 创建相同版本的sandbox
make_multiple_custom_sandbox :创建不同版本的sandbox
make_sandbox_from_source : 从build目录创建一个sandbox
make_sandbox_from_installed : 从已安装的二进制文件创建一个sandbox
sbtool : sandbox管理工具
11.查看各种授权
查看实例目录下的grants.mysql文件