James Little

mysqlslap for MySQL 5.0

7 comments

Last update: October 21st, 2009


{lang: 'en-GB'}

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:
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.23-rc.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/

2. Unpack the archive:
tar -xvvzf mysql-5.1.23-rc.tar.gz

3. 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
make
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
5. 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.

{lang: 'en-GB'}

Written by James Little

April 2nd, 2008 at 3:18 pm

Posted in Linux,MySQL

Tagged with ,

  • Jeremy

    In most cases, you won’t want to do a make install, especially if you have a previous version of mysql installed. I suggest a ‘make’, and then copy the file out of the client directory.

    This eliminates any overwriting of files into your standard path (/usr/local) and gives you the tool you want.

  • Thiru

    Thanks. Very useful.

  • http://i.ndustrio.us/2009/10/27/installing-mysqlslap-on-a-mediatemple-dv-wcentos5/ i.ndustrio.us » Installing mysqlslap on a MediaTemple DV w/CentOS5

    [...] have mysqlslap compiled in. If you come across that problem you add it pretty easily – follow James Little’s instructions here. * Be sure to first install the developer tools if you’re on a Media Temple DV machine. [...]

  • http://i.ndustrio.us/2009/10/29/links-for-2009-10-29/ i.ndustrio.us » links for 2009-10-29

    [...] mysqlslap for MySQL 5.0 | James Little [...]

  • Mail

    exactly!

  • Shrikant

    thanks it worked for me.

  • Abhijit

    Excellent! I tested MySQL 5.0 version by this method and it worked perfectly for me.
    Many Thanks, James!!!