Sysbench

Sysbench is a system performance benchmark initially developed for MySQL (now open to other database flavors like Oracle) but can also test your system performance without any database.

In this document we will see how to compile it on Red Hat Enterprise Linux Server release 5.2 (Tikanga) 32 bits with MySQL Enterprise 5.1.49sp1.

Please note that as Sysbench executable is linked to MySQL binaries (end header files) you should recompile it each time you change your MySQL release…

Get the latest source file from Sysbench web site. Then unzip/untar it and in root folder issue something like:

[root@server1 sysbench-0.4.12]# ./configure --with-mysql-includes=/mysql/software/5.1.49sp1/include --with-mysql-libs=/mysql/software/5.1.49sp1/lib

Where /mysql/software/5.1.49sp1 is your MySQL basedir…

Then create the executables:

[root@server1 sysbench-0.4.12]# make

Then it should failed for something like:

make[2]: Entering directory `/tmp/sysbench-0.4.12/sysbench'
/bin/sh ../libtool --tag=CC   --mode=link /usr/bin/gcc -pthread -g -O2      -o sysbench 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/mysql/software/5.1.49sp1/lib -lmysqlclient_r   -lrt -laio -lm
../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/mysql/software/5.1.49sp1/lib: No such file or directory
../libtool: line 2400: Xsysbench: command not found

There is an interesting post at, with the solution: Compiling sysbench 0.4.12 for Debian.

Which I copy/paste for Redhat if it disappears…

First time you issue autogen.sh you should get an error for missing executables:

[root@server1 sysbench-0.4.12]# ./autogen.sh
./autogen.sh: line 3: aclocal: command not found

We need additional packages:

[root@server1 sysbench-0.4.12]# rpm -Uvh http://rdbms.st.com/download/iso/Server/automake-1.9.6-2.1.noarch.rpm
Retrieving http://rdbms.st.com/download/iso/Server/automake-1.9.6-2.1.noarch.rpm
warning: /var/tmp/rpm-xfer.LPYoVQ: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
        autoconf >= 2.58 is needed by automake-1.9.6-2.1.noarch
[root@server1 sysbench-0.4.12]# rpm -Uvh http://rdbms.st.com/download/iso/Server/autoconf-2.59-12.noarch.rpm
Retrieving http://rdbms.st.com/download/iso/Server/autoconf-2.59-12.noarch.rpm
warning: /var/tmp/rpm-xfer.Hulnia: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
        imake is needed by autoconf-2.59-12.noarch
[root@server1 sysbench-0.4.12]# rpm -Uvh http://rdbms.st.com/download/iso/Server/autoconf-2.59-12.noarch.rpm http://rdbms.st.com/download/iso/Server/imake-1.0.2-3.i386.rpm
Retrieving http://rdbms.st.com/download/iso/Server/autoconf-2.59-12.noarch.rpm
Retrieving http://rdbms.st.com/download/iso/Server/imake-1.0.2-3.i386.rpm
warning: /var/tmp/rpm-xfer.XtEbuv: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:imake                  ########################################### [ 50%]
   2:autoconf               ########################################### [100%]
[root@server1 sysbench-0.4.12]# rpm -Uvh http://rdbms.st.com/download/iso/Server/automake-1.9.6-2.1.noarch.rpm
Retrieving http://rdbms.st.com/download/iso/Server/automake-1.9.6-2.1.noarch.rpm
warning: /var/tmp/rpm-xfer.irCLAp: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:automake               ########################################### [100%]

Let’s try again:

[root@server1 sysbench-0.4.12]# ./autogen.sh
sysbench/drivers/mysql/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/drivers/mysql/Makefile.am:17:
sysbench/drivers/mysql/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/drivers/mysql/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/drivers/oracle/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/drivers/oracle/Makefile.am:17:
sysbench/drivers/oracle/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/drivers/oracle/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/drivers/pgsql/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/drivers/pgsql/Makefile.am:17:
sysbench/drivers/pgsql/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/drivers/pgsql/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/tests/cpu/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/tests/cpu/Makefile.am:17:
sysbench/tests/cpu/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/tests/cpu/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/tests/fileio/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/tests/fileio/Makefile.am:17:
sysbench/tests/fileio/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/tests/fileio/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/tests/memory/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/tests/memory/Makefile.am:17:
sysbench/tests/memory/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/tests/memory/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/tests/mutex/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/tests/mutex/Makefile.am:17:
sysbench/tests/mutex/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/tests/mutex/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/tests/oltp/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/tests/oltp/Makefile.am:17:
sysbench/tests/oltp/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/tests/oltp/Makefile.am:17: to `configure.ac' and run `autoconf' again.
sysbench/tests/threads/Makefile.am:17: library used but `RANLIB' is undefined
sysbench/tests/threads/Makefile.am:17:
sysbench/tests/threads/Makefile.am:17: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
sysbench/tests/threads/Makefile.am:17: to `configure.ac' and run `autoconf' again.

Add AC_PROG_RANLIB in configure.ac near AC_PROG* other variables.

Now failing for:

[root@server1 sysbench-0.4.12]# ./autogen.sh
configure.ac:75: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.

Comment out AC_PROG_LIBTOOL in configure.ac near AC_PROG* other variables.

Shoudl work now:

[root@server1 sysbench-0.4.12]# ./autogen.sh

Then re-issue:

[root@server1 sysbench-0.4.12]# ./configure --with-mysql-includes=/mysql/software/5.1.49sp1/include --with-mysql-libs=/mysql/software/5.1.49sp1/lib
[root@server1 sysbench-0.4.12]# make
[root@server1 sysbench-0.4.12]# make install

Then again failing for:

[root@server1 sysbench-0.4.12]# sysbench
sysbench: error while loading shared libraries: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

A simple ldd shows what’s wrong:

[root@server1 sysbench-0.4.12]# ldd /usr/local/bin/sysbench
        linux-gate.so.1 =>  (0x00816000)
        libmysqlclient_r.so.16 => not found
        librt.so.1 => /lib/librt.so.1 (0x00b23000)
        libaio.so.1 => /usr/lib/libaio.so.1 (0x008ed000)
        libm.so.6 => /lib/libm.so.6 (0x00acc000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00af5000)
        libc.so.6 => /lib/libc.so.6 (0x00981000)
        /lib/ld-linux.so.2 (0x00963000)

Export the LD_LIBRARY_PATH variable:

[root@server1 /]# export LD_LIBRARY_PATH=/mysql/software/5.1.49sp1/lib
[root@server1 /]# ldd /usr/local/bin/sysbench
        linux-gate.so.1 =>  (0x0019e000)
        libmysqlclient_r.so.16 => /mysql/software/5.1.49sp1/lib/libmysqlclient_r.so.16 (0x00267000)
        librt.so.1 => /lib/librt.so.1 (0x00b23000)
        libaio.so.1 => /usr/lib/libaio.so.1 (0x00110000)
        libm.so.6 => /lib/libm.so.6 (0x00acc000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00af5000)
        libc.so.6 => /lib/libc.so.6 (0x00981000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x046ab000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00d9b000)
        /lib/ld-linux.so.2 (0x00963000)

You have done it:

[root@server1 /]# sysbench
Missing required command argument.
Usage:
  sysbench [general-options]... --test=<test-name> [test-options]... command
 
General options:
  --num-threads=N            number of threads to use [1]
  --max-requests=N           limit for total number of requests [10000]
  --max-time=N               limit for total execution time in seconds [0]
  --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE   size of stack per thread [32K]
  --init-rng=[on|off]        initialize random number generator [off]
  --test=STRING              test to run
  --debug=[on|off]           print more debugging info [off]
  --validate=[on|off]        perform validation checks where possible [off]
  --help=[on|off]            print help and exit
  --version=[on|off]         print version and exit
 
Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test
  oltp - OLTP test
 
Commands: prepare run cleanup help version
 
See 'sysbench --test=<name> help' for a list of options for each test.

Then to create the workload table in test database issue something like:

[root@server1 /]# sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=yjaquier --mysql-password=password --mysql-host=server1.domain.com  --mysql-port=3306  --max-time=60 --oltp-read-only=OFF --max-requests=0 --num-threads=2 prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
No DB drivers specified, using mysql
Creating table 'sbtest'...
Creating 1000000 records in table 'sbtest'...

To issue a benhmark run something like:

[root@server1 /]# sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=yjaquier --mysql-password=password --mysql-host=server1.domain.com --mysql-port=3306 --max-time=60 --oltp-read-only=off --max-requests=0 --num-threads=2 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 2
 
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Threads started!
Time limit exceeded, exiting...
(last message repeated 1 times)
Done.
 
OLTP test statistics:
    queries performed:
        read:                            61810
        write:                           22075
        other:                           8830
        total:                           92715
    transactions:                        4415   (73.56 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 83885  (1397.57 per sec.)
    other operations:                    8830   (147.11 per sec.)
 
Test execution summary:
    total time:                          60.0219s
    total number of events:              4415
    total time taken by event execution: 119.9186
    per-request statistics:
         min:                                 17.60ms
         avg:                                 27.16ms
         max:                                257.07ms
         approx.  95 percentile:              47.90ms
 
Threads fairness:
    events (avg/stddev):           2207.5000/3.50
    execution time (avg/stddev):   59.9593/0.00

One thought on “Sysbench

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>