Friday, July 27, 2012

Installing MySQL Sandbox on CentOS 6

MySQL sandbox is used to easily deploy MySQL instances for testing.  You can easily setup a single node, master-slave nodes, master-master nodes with one command.

More information on MySQL Sandbox is listed here:

To install MySQL sandbox, you will need compiler tools and MySQL dependencies.  Please refer to

1.  Install cpan 
yum install cpan

2.  Install build dependencies
yum install perl-Test-Simple

3.  Install MySQL sandbox
cpan MySQL::Sandbox

4.  Test if Sandbox is installed:
MySQL Sandbox should not run as root

If you know what you are doing and want to
 run as root nonetheless, please set the environment
variable 'SANDBOX_AS_ROOT' to a nonzero value

5.  Test is MySQL Sandbox can create one MySQL instance:
su - <regular user>
mysql_sandbox Percona-Server-5.5.25a-rel27.1-277.Linux.x86_64.tar.gz
mysql -umsandbox -pmsandbox --host= --port=5525

Installing sysbench from launchpad source on CentOS 6

Sysbench is used to benchmark servers on MySQL performance.  Though sysbench is available in official repositories, the version available on launchpad is capable of benchmarking load on multiple tables.  Since there's no package for it, we have to build it ourselves.  Here's how:

1.  Install compiler tools to compile the source 
yum -y install gcc gcc-c++ autoconf automake make libtool

2.  Install bzr so you download the source from the repository
yum -y install bzr

3.  Install MySQL dependencies to build sysbench:
yum -y install mysql mysql-server mysql-devel

4.  Download sysbench
bzr branch lp:sysbench

5.  Compile and install sysbench
cd sysbench
./configure --prefix=/usr --mandir=/usr/share/man
make install

6.  Copy lua templates
mkdir /usr/share/sysbench/tests/db -p
cp tests/db/* /usr/share/sysbench/tests/db

7.  Test if sysbench is working

Missing required command argument.
  sysbench [general-options]... --test=<test-name> [test-options]... command

Use "script" to record the commands you have executed

If you need documentation on the commands that you will perform on a linux shell, you can script to record it and store it in a file when you are finished:

138:myserver user$ script record.txt
Script started, output file is record.txt
bash-3.2$ whoami
bash-3.2$ exit

Script done, output file is record.txt
138:myserver user$ cat record.txt 
Script started on Fri Jul 27 23:02:44 2012
bash-3.2$ whoami
bash-3.2$ exit

Script done on Fri Jul 27 23:02:47 2012