Since Sysbench is an open source tool, there are several forks available. MySQL
maintains one of these forks; however, to get the version with the most recent features, it is recommended to use the fork by Alexey Kopytov. (This is also the fork recommended by MySQL performance architect Dimitri Kravtchuk.) The examples in this chapter all Table 3-2. (continued)
Benchmark Description
HammerDB the HammerDB tool is a free cross-database tool with support for both microsoft windows and Linux. it has support for the tpC-C and tpC-H benchmarks and is available from https://hammerdb.com/.
Database Factory
Database Factory is a powerful benchmark tool for microsoft windows that supports several databases and benchmarks. it supports the tpC-H, tpC-C, tpC-D, and tpC-e benchmarks and more. it is a commercial product (free trial available): www.quest.
com/products/benchmark-factory/.
iiBench iiBench is testing how fast you can insert data into the database and thus is useful if you regularly need to ingest large amount of data. it can be downloaded from https://github.com/tmcallaghan/iibench-mysql.
DVD Store Version 3
the DVD Store combines data for a sample DVD store with a benchmark. it can generate data for any given size with standard sizes being 10 mB, 1 gB, and 100 gB.
it is also useful as general test data and can be downloaded from https://github.
com/dvdstore/ds3. it is based on the older Dell DVD Store Database test Suite.
mysqlslap the mysqlslap tool is special as it is included with the mySQL installation. it can be used to generate a concurrent workload against a table of your choice. it is a very simple tool, so it cannot be used for too many purposes, but it is easy to use. the manual page for mysqlslap can be found at https://dev.mysql.com/doc/
refman/en/mysqlslap.html.
25 use Kopytov’s fork version 1.0.17 (but note the version listed on outputs is 1.1.0), but the examples will be similar for other Sysbench forks as long as the fork is new enough to include the features demonstrated.
There is support for installing Sysbench using native Linux packages, from
Homebrew on macOS, or to compile it yourself. While installing using native packages is simpler, it is in general better to compile yourself as it ensures you compile against the MySQL 8 development libraries, and you can compile Sysbench on more platforms than where there are packages available.
Tip For details about all the installation instructions, including required dependencies and using native packages, see https://github.com/
akopytov/sysbench. Support for microsoft windows has been dropped in Sysbench 1.0. it is currently unknown whether support will be reintroduced. if you are using microsoft windows, the recommendation is to install Sysbench through windows Subsystem for Linux (wSL) ( https://msdn.microsoft.com/en-us/
commandline/wsl/about) in which case the instruction in this chapter should work with minor modifications (depending on the Linux distribution you choose). an alternative is to use a virtual machine, for example, in VirtualBox.
Compiling software may not be very common any longer, but fortunately it is straightforward to compile Sysbench. You will need to download the source code and then configure the build, compile it, and finally install it.
There are some tools you will need to install before you can compile Sysbench. The exact tools required depend on your operating system. See the installation instructions on the project’s GitHub page for details. For example, on Oracle Linux 7:
shell$ sudo yum install make automake libtool \ pkgconfig libaio-devel \ openssl-devel
You will also need to have the MySQL 8 development libraries installed. The easiest way to do this on Linux is to install the MySQL repository for your Linux distribution from https://dev.mysql.com/downloads/. Listing 3-1 shows an example of installing the MySQL 8 development libraries on Oracle Linux 7.
CHapter 3 BenCHmarking witH SySBenCH
Listing 3-1. Installing the MySQL 8 development libraries
shell$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.
noarch.rpm ...
Saving to: 'mysql80-community-release-el7-3.noarch.rpm' 100%[=================>] 26,024 --.-K/s in 0.006s
2019-10-12 14:21:18 (4.37 MB/s) - 'mysql80-community-release-el7-3.noarch.
rpm' saved [26024/26024]
shell$ sudo yum install mysql80-community-release-el7-3.noarch.rpm Loaded plugins: langpacks, ulninfo
Examining mysql80-community-release-el7-3.noarch.rpm: mysql80-community- release-el7-3.noarch
Marking mysql80-community-release-el7-3.noarch.rpm to be installed Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-3 will be installed --> Finished Dependency Resolution
Dependencies Resolved
===========================================================
Package
Arch Version
Repository Size
===========================================================
Installing:
mysql80-community-release noarch el7-3
/mysql80-community-release-el7-3.noarch 31 k Transaction Summary
===========================================================
Install 1 Package Total size: 31 k
27 Installed size: 31 k
Is this ok [y/d/N]: y Downloading packages:
Running transaction check Running transaction test Transaction test succeeded Running transaction
Installing : mysql80-community-release-el7-3.noarc 1/1 Verifying : mysql80-community-release-el7-3.noarc 1/1 Installed:
mysql80-community-release.noarch 0:el7-3 Complete!
shell$ sudo yum install mysql-devel ...
Dependencies Resolved
===========================================================
Package Arch Version Repository Size
===========================================================
Installing:
mysql-community-client
x86_64 8.0.17-1.el7 mysql80-community 32 M replacing mariadb.x86_64 1:5.5.64-1.el7
mysql-community-devel
x86_64 8.0.17-1.el7 mysql80-community 5.5 M mysql-community-libs
x86_64 8.0.17-1.el7 mysql80-community 3.0 M replacing mariadb-libs.x86_64 1:5.5.64-1.el7 mysql-community-libs-compat
x86_64 8.0.17-1.el7 mysql80-community 2.1 M replacing mariadb-libs.x86_64 1:5.5.64-1.el7 mysql-community-server
x86_64 8.0.17-1.el7 mysql80-community 415 M replacing mariadb-server.x86_64 1:5.5.64-1.el7
CHapter 3 BenCHmarking witH SySBenCH
Installing for dependencies:
mysql-community-common
x86_64 8.0.17-1.el7 mysql80-community 589 k Transaction Summary
===========================================================
Install 5 Packages (+1 Dependent package) Total download size: 459 M
...
Complete!
The output depends on what you have already installed. Notice how several other MySQL packages, including mysql-community-server, are pulled in as dependencies.
This is because the mysql-community-devel package in this case replaces another preexisting package which triggers a chain of dependency updates.
Note if you have an older version of mySQL or a fork installed, all related packages will be upgraded. For this reason, it is best to compile Sysbench on a host where you can freely replace packages or the correct mySQL 8 development libraries are already installed.
You are now ready to consider Sysbench itself. You can choose to either clone the GitHub repository or download the source as a ZIP file. To clone the repository, you need to have git installed and then use the git clone command:
shell$ git clone https://github.com/akopytov/sysbench.git Cloning into 'sysbench'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 9740 (delta 4), reused 5 (delta 2), pack-reused 9726 Receiving objects: 100% (9740/9740), 4.12 MiB | 2.12 MiB/s, done.
Resolving deltas: 100% (6958/6958), done.
29 The ZIP file with the source code can be downloaded from the GitHub repository, for example, using wget:
shell$ wget https://github.com/akopytov/sysbench/archive/master.zip ...
Connecting to codeload.github.com (codeload.github.
com)|52.63.100.255|:443... connected.
HTTP request sent, awaiting response... 200 OK Length: unspecified [application/zip]
Saving to: 'master.zip'
[ <=> ] 2,282,636 3.48MB/s in 0.6s 2019-10-12 16:01:33 (3.48 MB/s) - 'master.zip' saved [2282636]
Alternatively, you can download the ZIP file using your browser as shown in Figure 3-1.
Click Download ZIP and the file will download. Once the source code is downloaded, unzip it.
Figure 3-1. Downloading the Sysbench source code from GitHub in a browser
CHapter 3 BenCHmarking witH SySBenCH
You are now ready to configure the compilation. Enter the top-level directory with the source code. The directory listing should look similar to the following output:
shell$ ls
autogen.sh COPYING Makefile.am rpm tests ChangeLog debian missing scripts third_party config install-sh mkinstalldirs snap
configure.ac m4 README.md src
The configuration is done using the autogen.sh script followed by the configure command as shown in Listing 3-2.
Listing 3-2. Configuring Sysbench for compilation and installation shell$ ./autogen.sh
autoreconf: Entering directory `.' ...
parallel-tests: installing 'config/test-driver' autoreconf: Leaving directory `.'
shell$ ./configure
checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu ...
===========================================================================
sysbench version : 1.1.0-74f3b6b CC : gcc -std=gnu99
CFLAGS : -O3 -funroll-loops -ggdb3 -march=core2 -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-
prototypes -Wnested-externs -Wno-format-zero-length -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -Wvla -pthread
CPPFLAGS : -D_GNU_SOURCE -I$(top_srcdir)/src -I$(abs_top_
builddir)/third_party/luajit/inc -I$(abs_top_
builddir)/third_party/concurrency_kit/include LDFLAGS : -L/usr/local/lib
LIBS : -laio -lm
31 prefix : /usr/local
bindir : ${prefix}/bin libexecdir : ${prefix}/libexec mandir : ${prefix}/share/man datadir : ${prefix}/share MySQL support : yes
PostgreSQL support : no LuaJIT : bundled
LUAJIT_CFLAGS : -I$(abs_top_builddir)/third_party/luajit/inc
LUAJIT_LIBS : $(abs_top_builddir)/third_party/luajit/lib/libluajit- 5.1.a -ldl
LUAJIT_LDFLAGS : -rdynamic Concurrency Kit : bundled
CK_CFLAGS : -I$(abs_top_builddir)/third_party/concurrency_kit/
include
CK_LIBS : $(abs_top_builddir)/third_party/concurrency_kit/lib/
libck.a configure flags :
===========================================================================
The end of the configuration shows the options that will be used for the compilation.
Make sure that MySQL support says yes. The default is to install in /usr/local. You can change that using the --prefix option when executing configure, for example,
./configure --prefix=/home/myuser/sysbench.
The next step is to compile the code which is done using the make command:
shell$ make -j
Making all in third_party/luajit ...
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/home/myuser/git/sysbench'
The -j option tells make to compile the source in parallel which can reduce the compilation time. However, Sysbench is in all cases quick to compile, so it is not of great importance in this case.
CHapter 3 BenCHmarking witH SySBenCH
The final step is to install the compiled version of Sysbench:
shell$ sudo make install
Making install in third_party/luajit ...
make[2]: Leaving directory `/home/myuser/git/sysbench' make[1]: Leaving directory `/home/myuser/git/sysbench'
That is it. You are now ready to use Sysbench to perform benchmark.