MySQL::Sandbox这东西用起来还真简单……可以快速地安装一个或者一组mysql服务端程序。安装的时候使用root用户,只需要一条命令就搞定:# cpan MySQL::Sandbox日常使用的时候,就不需要root权限了。以用户modify为例:1) 建立一个存放mysql源程序的仓库,并设置环境变量。[modify@H209 ~]$ mkdir /home/modify/mysql#这行指令应该要添加到 /home/modify/.bashrc文件中。[modify@H209 ~]$ export SANDBOX_BINARY=/home/modify/mysql 2) 下载mysql5.6.10的安装文件 (mysql-5.6.10-linux-glibc2.5-i686.tar.gz) 281.7M到/home/modify/mysql目录中。[modify@H209 ~]$ ls /home/modify/mysqlmysql-5.6.10-linux-glibc2.5-i686.tar.gz3) 创建第一个sandbox:第一次需要解压,所以时间会长一些[modify@H209 ~]$ make_sandbox /home/modify/mysql/mysql-5.6.10-linux-glibc2.5-i686.tar.gz unpacking /home/modify/mysql/mysql-5.6.10-linux-glibc2.5-i686.tar.gzExecuting low_level_make_sandbox --basedir=/home/modify/mysql/5.6.10 --sandbox_directory=msb_5_6_10 --install_version=5.6 --sandbox_port=5610 --no_ver_after_name --my_clause=log-error=msandbox.err>>/tmp<<5.6>>The MySQL Sandbox,version 3.0.30(C) 2006-2013 Giuseppe Maxiainstalling with the following parameters:upper_directory= /home/modify/sandboxessandbox_directory= msb_5_6_10sandbox_port = 5610check_port = no_check_port= datadir_from = scriptinstall_version= 5.6basedir= /home/modify/mysql/5.6.10tmpdir = my_file= operating_system_user= modifydb_user= msandboxremote_access= 127.%ro_user= msandbox_rorw_user= msandbox_rwrepl_user= rsandboxdb_password= msandboxrepl_password= rsandboxmy_clause= log-error=msandbox.errmaster = slaveof= high_performance = prompt_prefix= mysqlprompt_body=[h] {u} (d) > force= no_ver_after_name= 1verbose= load_grants= 1no_load_grants = no_run = no_show= do you agree? ([Y],n)安装之后的文件存在于 /home/modify/sandboxes/msb_5_6_10 目录中。而且已经启动了mysqld.[modify@H209 ~]$ ls /home/modify/sandboxes/clear_allmsb_5_6_10plugin.confrestart_allsandbox_actionsend_kill_allstart_allstatus_allstop_alluse_all 4)连接到sandbox:[root@H209 modify]# /home/modify/sandboxes/msb_5_6_10/use Welcome to the MySQL monitor.Commands end with ; or g.Your MySQL connection id is 3Server version: 5.6.10 MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type "help;" or "h" for help. Type "c" to clear the current input statement. mysql [localhost] {msandbox} ((none)) > mysql [localhost] {msandbox} ((none)) > select user();+--------------------+| user() |+--------------------+| msandbox@localhost |+--------------------+1 row in set (0.00 sec)5) 再创建一个5.6.10的sandbox:在第一次创建之后,源程序仓库中已经有了一个名为5.6.10的目录,其实就是从mysql-5.6.10-linux-glibc2.5-i686.tar.gz中解压出来的:[modify@H209 ~]$ ls /home/modify/mysql5.6.10mysql-5.6.10-linux-glibc2.5-i686.tar.gz 此时再创建5.6.10的sandbox,就比较简单了:[modify@H209 ~]$ make_sandbox 5.6.10......upper_directory= /home/modify/sandboxessandbox_directory= msb_5_6_10sandbox_port = 5610check_port = no_check_port= datadir_from = script............do you agree? ([Y],n) y 然后提示: /home/modify/sandboxes/msb_5_6_10 already exists.不止这个目录会冲突,mysqld使用的端口也会冲突,于是还要加一个参数:[modify@H209 ~]$ make_sandbox 5.6.10 -- --check_port......upper_directory= /home/modify/sandboxessandbox_directory= msb_5_6_10_asandbox_port = 5611..... 安装目录变成了 msb_5_6_10_a, 端口也加了1,变为5611,相当智能。 [modify@H209 ~]$ ls /home/modify/sandboxes/msb_5_6_10_a/change_pathscleargrants.mysqlmsbmy.sandbox.cnfrescue_mysql_dump.sqlsend_killstatustmpUSINGchange_portsdata load_grants my proxy_start restartstartstopuse 此目录中的start, stop, restart用于启动,关闭,重启mysqld。6) sbtool 此命令可以copy ,move, change port,delete某个sandbox。详情看文档。 7) make_replication_sandbox可以创建一主二从(当然这个结构也是可以用参数来调整的)。[modify@H209 ~]$ make_replication_sandbox5.6.10installing and starting masterinstalling slave 1installing slave 2starting slave 1... sandbox server startedstarting slave 2... sandbox server startedinitializing slave 1initializing slave 2replication directory installed in $HOME/sandboxes/rsandbox_5_6_10 [modify@H209 ~]$ ls /home/modify/sandboxes/rsandbox_5_6_10/check_slavesclear_allenable_gtidinitialize_slavesmmasternode1node2restart_alls1s2send_kill_allstart_allstatus_allstop_alluse_all 此目录中的m相当于use master, s1相当于use slave 1, s2相当于 use slave 2。 [modify@H209 ~]$ /home/modify/sandboxes/rsandbox_5_6_10/s2 Warning: /home/modify/.mylogin.cnf should be readable/writable only by current user.Welcome to the MySQL monitor.Commands end with ; or g.Your MySQL connection id is 5Server version: 5.6.10-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type "help;" or "h" for help. Type "c" to clear the current input statement. slave2 [localhost] {msandbox} ((none)) > show slave status G*************************** 1. row *************************** Slave_IO_State: Waiting for master to send eventMaster_Host: 127.0.0.1Master_User: rsandboxMaster_Port: 18675Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 2590 Relay_Log_File: mysql_sandbox18677-relay-bin.000002Relay_Log_Pos: 2753Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table:Last_Errno: 0 Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 2590Relay_Log_Space: 2939Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File:Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher:Master_SSL_Key: Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids:Master_Server_Id: 1Master_UUID: c52c239c-78d6-11e2-917f-00241db92e69 Master_Info_File: /home/modify/sandboxes/rsandbox_5_6_10/node2/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 01 row in set (0.00 sec) slave2 [localhost] {msandbox} ((none)) >没有使用到最新的Auto_Position与GTID,有点遗憾。使用MySQL的镜像功能进行数据同步MySQL 5.6主从复制第一部分[简介及配置]相关资讯 MySQL教程
- 30分钟带你快速入门MySQL教程 (02月03日)
- MySQL教程:关于I/O内存方面的一些 (01月24日)
- 生产环境MySQL 5.5.x单机多实例配 (11/02/2012 21:02:36)
| - MySQL教程:关于checkpoint机制 (01月24日)
- CentOS上开启MySQL远程访问权限 (01/29/2013 10:58:40)
- MySQL的LAST_INSERT_ID用法举例 (10/15/2012 16:03:40)
|
本文评论 查看全部评论 (0)