mysqlslap is a very useful tool for emulating client load, something that would normally be very difficult in the real world (until you go live!). The binary is bundled into the MySQL 5.1 releases (still at Release Candidate stage) but not 5.0, so the only option is to compile from 5.1 source and then you can use it with your 5.0 server installation.

Fortunately when compiling you can save some time by configuring with the --without-server option, which will compile just the client tools (mysqldump, mysqlbinlog, mysql CLI, etc.). The following worked for me on an installation of CentOS5 64-bit, on the same machine that runs my 5.0 server.

1. Download the MySQL 5.1 source code in compressed tar format (.tar.gz). Go to the download page, or do a wget (in my case from the Mirror Service from the University of Kent, UK). Version 5.1.23-rc was current at the time of writing:

  1. Unpack the archive:
tar -xvvzf mysql-5.1.23-rc.tar.gz
  1. Install required development packages and compile:
cd mysql-5.1.23-rc
yum install glibc gcc libtool ncurses-devel gcc-c++
./configure --without-server --disable-shared
sudo make install

The make stage will take some time. Why configure with --disable-shared? I wanted my binary to be portable so I could share amongst a group of similar-spec machines, and I can't be sure that the shared libraries are all in the same location. See the MySQL Installation pages for more details on configuration options; you may want to make use of --libdir=... instead.

4. Copy/move the mysqlslap binary (it will be in /usr/local/bin by default) to wherever the rest of your v5.0 client binaries are. For example:

cp /usr/local/bin/mysqlslap  /usr/local/mysql/bin/mysqlslap``
  1. Test it out! Run something like:
./mysqlslap --user=root --auto-generate-sql --concurrency=100 --iterations=5``

as a quick test, and check out the MySQL Documentation for a more detailed use-guide.

Since compiling I have thrown the binary around various other Intel machines (and VMs) running CentOS, without any problems.


comments powered by Disqus