Mar 02 2010

Compiling SysBench on Debian Lenny

Tag: Debian,English,HW Tunning,Linux,MySQLJens @ 23:00

SysBench is a system performance benchmark primarily written for MySQL server benchmarking. In actual version 0.4.12, SysBench supports different benchmark modes: file I/O performance, CPU and scheduler performance, memory allocation and transfer speed, threads implementation performance and database server performance. It’s widely used on Linux machines, especially for identifying bottlenecks on database servers (with using file I/O performance and MySQL database support).

There are no exists pre-compiled binary package on current stable Debian (Lenny). If you want to use SysBench on this version, there are at least two different options:

  1. use pre-compiled package from unstable (Squeeze) version,
  2. compile itself from source SysBench package.

With the first option, there are two problems, why it is not a good idea: 1) mixing stable and unstable packages and 2) unstable Debian package don’t contains last version of SysBench (currently contains version 0.4.10-1).

In compilation SysBench from source, they may occurs some problems:

  • Wrong machine/OS detection in compile configuration phase:
    # ./configure
    checking build system type... Invalid configuration `x86_64-unknown-linux-': machine `x86_64-unknown-linux' not recognized
    configure: error: /bin/sh config/config.sub x86_64-unknown-linux- failed
  • Unreachable binary mysql_configor undetectable location of MySQL libraries, which are required for SysBench MySQL support:
    ********************************************************************************
    ERROR: cannot find MySQL libraries. If you want to compile with MySQL support,
           you must either specify file locations explicitly using
           --with-mysql-includes and --with-mysql-libs options, or make sure path to
           mysql_config is listed in your PATH environment variable. If you want to
           disable MySQL support, use --without-mysql option.
    ********************************************************************************
    This could be easy solved with installing libmysqlclient15-dev debian package.
  • libtoolerror in compilation progress
    # make
    ... some lines cropped ...
    ../libtool: line 838: X--tag=CC: command not found
    ../libtool: line 871: libtool: ignoring unknown tag : command not found
    ../libtool: line 838: X--mode=link: command not found
    ../libtool: line 1004: *** Warning: inferring the mode of operation is deprecated.: command not found
    ../libtool: line 1005: *** Future versions of Libtool will require --mode=MODE be specified.: command not found
    ../libtool: line 2231: X-g: command not found
    ../libtool: line 2231: X-O2: command not found
    ../libtool: line 1951: X-L/usr/lib/mysql: No such file or directory
    ../libtool: line 2400: Xsysbench: command not found
    ../libtool: line 2405: X: command not found
    ../libtool: line 2412: Xsysbench: command not found
    ../libtool: line 2420: mkdir /.libs: No such file or directory
    ../libtool: line 2547: X-lmysqlclient_r: command not found
    ../libtool: line 2547: X-lrt: command not found
    ../libtool: line 2547: X-lm: command not found
    ../libtool: line 2629: X-L/root/sysbench-0.4.12/sysbench: No such file or directory
    ../libtool: line 2547: X-lmysqlclient_r: command not found
    ../libtool: line 2547: X-lrt: command not found
    ../libtool: line 2547: X-lm: command not found
    ../libtool: line 2629: X-L/root/sysbench-0.4.12/sysbench: No such file or directory
    ../libtool: line 2547: X-lmysqlclient_r: command not found
    ../libtool: line 2547: X-lrt: command not found
    ../libtool: line 2547: X-lm: command not found
    ../libtool: line 5162: Xgcc -pthread "" "" -o @OUTPUT@ sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/root/sysbench-0.4.12/sysbench -lmysqlclient_r -lrt -lm: No such file or directory
    ../libtool: line 5163: Xgcc -pthread "" "" -o @OUTPUT@ sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/root/sysbench-0.4.12/sysbench -lmysqlclient_r -lrt -lm: No such file or directory
    ../libtool: line 5168: X: command not found
    ../libtool: line 5172: : command not found
    ... some lines cropped ...

Compilation step-by-step

Prerequisites: gcc, make and automake for compilation, mysql-server and libmysqlclient15-dev for MySQL support.

# apt-get install gcc make automake mysql-server libmysqlclient15-dev

Obtaining source code (actual version may differ) and extract archive:

# wget http://downloads.sourceforge.net/project/sysbench/sysbench/0.4.12/sysbench-0.4.12.tar.gz
# tar xfz sysbench-0.4.12.tar.gz
# cd sysbench-0.4.12

Fixing wrong machine/OS detection in configuration phase: edit file config/config.sub and before line line 312 (or line, where is comment: # Object if more than one company name word.) add following lines (with respect your machine/distro, in our case x86_64-unknown-linux; ensured from error message).

x86_64-unknown-linux)
    basic_machine=x86_64-pc
    os=-linux
    ;;

Fixing libtool error via replacing ranlib in file configure.ca, at line 75 (change AC_PROG_LIBTOOL to AC_PROG_RANLIB) and recreate all automake utilities with autogen:

# sed -i configure.ac -e 's/AC_PROG_LIBTOOL/AC_PROG_RANLIB/'
# ./autogen.sh

Now, you should run classical compilation progress:

./configure
make
make install

That’s all, sysbench binary is created in sysbench directory (sysbench/sysbench), you can copy it into some PATH folder and use it as you wish:

# cp sysbench/sysbench /usr/bin/sysbench

Some useful links