System Installation
Binary Repositories
Precompiled packages are available for major Linux distributions via the official repository script.
# Debian/Ubuntu ecosystems
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash
sudo apt install sysbench -y
# RHEL/CentOS/Fedora ecosystems
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
sudo dnf install sysbench -y
Source Compilation
Building from source provides flexibility for custom environments or specific version requirements.
# Resolve build dependencies
sudo yum groupinstall "Development Tools" -y
sudo yum install mysql-devel git autoconf automake libtool -y
# Fetch and configure
git clone --branch 1.0.22 https://github.com/akopytov/sysbench.git
cd sysbench
./autogen.sh
./configure --prefix=/usr/local/sysbench --mandir=/usr/share/man
make -j$(nproc)
sudo make install
Operational Parameters
Sysbench v1.0+ utilizes a subcommand structure: sysbench <test> <command> [options].
| Command | Function |
|---|---|
prepare |
Generates test fixtures, database tables, or disk files required for execution. |
run |
Executes the configured workload against the target subsystem. |
cleanup |
Removes all artifacts created during the prepare phase. |
help |
Displays syntax and available flags for the specified test module. |
Core Configuration Flags
- Concurrency & Timing:
--threads=N,--time=60,--max-requests=0(unlimited) - Reporting Metrics:
--report-interval=5,--percentile=99,--histogram=on - Randomization Engine:
--rand-type={uniform,gaussian,zipfian} - Database Connectivity:
--db-driver=mysql,--mysql-host=addr,--mysql-user=bench_admin,--mysql-password=secret
Workload Execution
Database OLTP Benchmark
The following sequence initializes an InnoDB tablespace, executes mixed read/write transactions, and purges data.
# Connection and concurrency variables
DB_HOST="127.0.0.1"
DB_PORT="3306"
DB_USER="benchmark_admin"
DB_PASS="secure_password"
WORKER_COUNT=16
# Phase 1: Table initialization
sysbench oltp_read_write \
--db-driver=mysql \
--mysql-host="$DB_HOST" \
--mysql-port="$DB_PORT" \
--mysql-user="$DB_USER" \
--mysql-password="$DB_PASS" \
--tables=50 \
--table-size=100000 \
prepare
# Phase 2: Transaction execution
sysbench oltp_read_write \
--db-driver=mysql \
--mysql-host="$DB_HOST" \
--mysql-port="$DB_PORT" \
--mysql-user="$DB_USER" \
--mysql-password="$DB_PASS" \
--tables=50 \
--table-size=100000 \
--threads="$WORKER_COUNT" \
--time=120 \
--percentile=95 \
run
# Phase 3: Artifact removal
sysbench oltp_read_write \
--db-driver=mysql \
--mysql-host="$DB_HOST" \
--mysql-port="$DB_PORT" \
--mysql-user="$DB_USER" \
--mysql-password="$DB_PASS" \
cleanup
CPU Subsystem
Evaluates integer arithmetic performance through prime number calculation.
sysbench cpu \
--threads=8 \
--cpu-max-prime=20000 \
run
Memory Trhoughput
Measures sequential random access bandwidth across allocated memory blocks.
sysbench memory \
--memory-block-size=16K \
--memory-total-size=4G \
--num-threads=4 \
--memory-access-mode=seq \
run
Storage I/O
Provisions temporary files on the target filesystem and measures read/write latency.
TARGET_DIR="/tmp/benchmark_io"
FILE_SIZE="10G"
mkdir -p "$TARGET_DIR" && cd "$TARGET_DIR"
# Provision storage artifacts
sysbench fileio \
--file-num=16 \
--file-total-size="$FILE_SIZE" \
--file-block-size=16384 \
prepare
# Execute random read pattern
sysbench fileio \
--file-num=16 \
--file-total-size="$FILE_SIZE" \
--file-block-size=16384 \
--file-test-mode=rndrd \
run
# Remove generated files
sysbench fileio \
--file-num=16 \
--file-total-size="$FILE_SIZE" \
cleanup