openSUSE

How To Install Sysbench on openSUSE

Install Sysbench on openSUSE

In today’s performance-driven computing world, properly benchmarking your system is essential for optimal operation. Sysbench stands out as a powerful, versatile benchmarking tool that allows Linux users to test various system components and make informed optimization decisions. For openSUSE users specifically, installing and configuring Sysbench provides valuable insights into system performance that can guide hardware upgrades and software configurations. This comprehensive guide walks you through everything you need to know about installing Sysbench on openSUSE, from basic setup to advanced usage scenarios.

Understanding Sysbench and Its Benefits

Sysbench is a modular, cross-platform benchmarking tool designed to evaluate system performance under various workloads. Originally developed to test MySQL performance, it has evolved into a comprehensive benchmarking solution that can assess CPU performance, memory access, file I/O operations, thread scheduling, database performance, and much more.

Key advantages of Sysbench include:

  • Multi-component testing capabilities that allow for comprehensive system evaluation
  • Customizable test parameters to simulate real-world workloads
  • Cross-platform compatibility across different Linux distributions
  • Scriptable benchmarking through Lua scripting support
  • Detailed performance metrics for thorough analysis
  • Active community support and regular updates

For openSUSE administrators and users, Sysbench provides critical performance data that helps identify system bottlenecks, verify hardware performance, and optimize configurations. Whether you’re running a web server, database server, or development environment, Sysbench offers valuable insights that guide decision-making for system upgrades and tuning.

Prerequisites for Installation

Before installing Sysbench on your openSUSE system, ensure you have the following prerequisites in place:

System Requirements:

  • A working openSUSE installation (Tumbleweed, Slowroll, or Leap)
  • Root or sudo access for installation
  • At least 100MB of free disk space
  • Basic knowledge of terminal commands
  • Internet connectivity for repository access

Verification Steps:

  1. Check your openSUSE version:
    cat /etc/os-release
  2. Ensure your system is up-to-date:
    sudo zypper update
  3. Verify you have sufficient privileges to install packages:
    sudo zypper verify
  4. Check for any existing Sysbench installations:
    rpm -q sysbench

If you plan to use Sysbench for database benchmarking, you’ll also need:

  • MySQL or MariaDB server installed and configured
  • Database connection credentials with appropriate permissions
  • Development libraries if compiling from source

Installation Method 1: Using Official Repositories

Installing Sysbench using openSUSE’s package repositories is the simplest and most recommended method for most users. The process varies slightly depending on which openSUSE version you’re using.

For openSUSE Tumbleweed

Tumbleweed is openSUSE’s rolling release distribution that provides the latest stable software packages. To install Sysbench on Tumbleweed:

  1. Open a terminal window
  2. Add the benchmark repository:
    sudo zypper addrepo https://download.opensuse.org/repositories/benchmark/openSUSE_Tumbleweed/benchmark.repo
  3. Refresh your repository information:
    sudo zypper refresh
  4. Install Sysbench:
    sudo zypper install sysbench
  5. Verify the installation:
    sysbench --version

For openSUSE Slowroll

Slowroll provides a more conservative update cycle while still offering reasonably fresh software. To install Sysbench on Slowroll:

  1. Add the benchmark repository:
    sudo zypper addrepo https://download.opensuse.org/repositories/benchmark/openSUSE_Slowroll/benchmark.repo
  2. Refresh your repository information:
    sudo zypper refresh
  3. Install Sysbench:
    sudo zypper install sysbench

For openSUSE Leap 15.6

Leap is openSUSE’s regular release version that focuses on stability. For openSUSE Leap 15.6 users:

  1. Add the benchmark repository:
    sudo zypper addrepo https://download.opensuse.org/repositories/benchmark/15.6/benchmark.repo
  2. Refresh your repository information:
    sudo zypper refresh
  3. Install Sysbench:
    sudo zypper install sysbench

Alternative Repository Option

If you prefer, you can also use the home:ecsos repository, which may offer different versions of Sysbench:

For openSUSE Tumbleweed:

sudo zypper addrepo https://download.opensuse.org/repositories/home:ecsos/openSUSE_Tumbleweed/home:ecsos.repo
sudo zypper refresh
sudo zypper install sysbench

For openSUSE Slowroll:

sudo zypper addrepo https://download.opensuse.org/repositories/home:ecsos/openSUSE_Slowroll/home:ecsos.repo
sudo zypper refresh
sudo zypper install sysbench

For Leap 15.6:

sudo zypper addrepo https://download.opensuse.org/repositories/home:ecsos/15.6/home:ecsos.repo
sudo zypper refresh
sudo zypper install sysbench

Installation Method 2: Compiling from Source Code

While repository installation is convenient, compiling Sysbench from source provides several advantages:

  • Access to the latest features and improvements
  • Ability to customize compilation with specific options
  • Performance optimizations for your particular system
  • Flexibility to modify the code if needed

Here’s how to compile and install Sysbench from source on openSUSE:

  1. First, install the required development tools and dependencies:
    sudo zypper install git automake libtool pkg-config gcc-c++ make
  2. If you plan to use MySQL/MariaDB benchmarking, install the development libraries:
    sudo zypper install mariadb-devel
  3. Clone the Sysbench repository:
    git clone https://github.com/akopytov/sysbench.git
    cd sysbench
  4. Alternatively, download a specific stable release:
    wget https://github.com/akopytov/sysbench/archive/refs/tags/1.0.20.tar.gz
    tar xf sysbench-1.0.20.tar.gz
    cd sysbench-1.0.20
  5. Generate the configuration scripts:
    ./autogen.sh
  6. Configure the build:
    ./configure

    For custom MySQL library paths, use:

    ./configure --with-mysql-includes=/path/to/mysql/includes --with-mysql-libs=/path/to/mysql/libs
  7. Compile the source code:
    make -j $(nproc)
  8. Install Sysbench system-wide:
    sudo make install
  9. Verify the installation:
    sysbench --version

Verifying Your Installation

After installing Sysbench, it’s essential to verify that it’s working correctly. Here are several methods to confirm your installation is successful:

  1. Check the installed version:
    sysbench --version
  2. View the help information to ensure all components are available:
    sysbench --help
  3. Run a simple CPU benchmark test:
    sysbench cpu --cpu-max-prime=1000 run
  4. Check the Sysbench binary location:
    which sysbench
  5. Verify all required libraries are properly linked:
    ldd $(which sysbench)

If you encounter any missing libraries, you may need to install additional packages or set up environment variables like LD_LIBRARY_PATH to point to the correct library locations.

Basic CPU Benchmarking Guide

CPU benchmarking is one of the most fundamental tests Sysbench can perform. It helps assess your processor’s performance under different workloads.

Running a Single-Threaded CPU Test:

sysbench cpu --cpu-max-prime=10000 run

This command calculates prime numbers up to 10,000, providing metrics like execution time and events per second.

Running a Multi-Threaded CPU Test:

sysbench cpu --cpu-max-prime=10000 --threads=4 run

The --threads parameter specifies how many parallel threads to use. Ideally, set this to match your CPU’s core count for optimal testing.

Understanding CPU Test Parameters:

  • --cpu-max-prime: Sets the highest prime number to calculate (higher values = longer tests)
  • --threads: Number of threads to use (test multiple cores)
  • --time: Maximum execution time in seconds
  • --events: Maximum number of events to execute

Sample Output Analysis:

CPU speed:
    events per second:   1134.89

General statistics:
    total time:                          10.0001s
    total number of events:              11349

Latency (ms):
         min:                                  0.85
         avg:                                  0.88
         max:                                  4.46
         95th percentile:                      0.90

The most important metrics to look for are “events per second” (higher is better) and “avg” latency (lower is better).

Memory Benchmarking Guide

Memory performance significantly impacts overall system speed. Sysbench’s memory tests help you evaluate memory access speed and bandwidth.

Running a Basic Memory Test:

sysbench memory --memory-block-size=1K --memory-total-size=10G run

This command reads/writes 10GB of data in 1KB blocks.

Important Memory Test Parameters:

  • --memory-block-size: Size of each memory block to allocate
  • --memory-total-size: Total size of data to transfer
  • --memory-scope: Memory access scope (global or local)
  • --memory-hugetlb: Use HugeTLB for allocations (0 or 1)
  • --memory-oper: Type of memory operations (read, write, or both)
  • --memory-access-mode: Memory access mode (seq or rnd)

Running a Sequential vs. Random Access Test:

Sequential access:

sysbench memory --memory-block-size=1K --memory-total-size=1G --memory-access-mode=seq run

Random access:

sysbench memory --memory-block-size=1K --memory-total-size=1G --memory-access-mode=rnd run

Compare the “MiB/sec” values between these tests to see how your memory performs under different access patterns.

File I/O Benchmarking Guide

File I/O benchmarking helps evaluate the performance of your storage devices, which is crucial for database and application performance.

Preparing the Test Files:

sysbench fileio --file-total-size=3G prepare

This creates test files totaling 3GB in the current directory.

Running Sequential Read Test:

sysbench fileio --file-total-size=3G --file-test-mode=seqrd --time=60 run

Running Random Read/Write Test:

sysbench fileio --file-total-size=3G --file-test-mode=rndrw --time=60 run

Important File I/O Parameters:

  • --file-total-size: Total size of test files
  • --file-test-mode: Test mode (seqrd, seqwr, seqrewr, rndrd, rndwr, rndrw)
  • --file-block-size: Size of I/O operations
  • --file-io-mode: File operations mode (sync, async, or mmap)
  • --file-extra-flags: Additional flags to use with open()

Cleaning Up After Tests:

sysbench fileio --file-total-size=3G cleanup

Always run this command after completing I/O tests to remove the temporary test files.

MySQL/MariaDB Database Benchmarking

Database performance benchmarking is one of Sysbench’s strongest features, allowing you to simulate real-world database workloads.

Preparing the Database:

  1. Ensure your MySQL/MariaDB server is running and you have credentials with appropriate permissions.
  2. Create a test database:
    mysql -u root -p -e "CREATE DATABASE sysbench_test;"
  3. Prepare the test tables:
    sysbench oltp_read_write --table-size=1000000 --db-driver=mysql --mysql-host=localhost --mysql-db=sysbench_test --mysql-user=root --mysql-password=your_password prepare

Running an OLTP Read/Write Test:

sysbench oltp_read_write --table-size=1000000 --db-driver=mysql --mysql-host=localhost --mysql-db=sysbench_test --mysql-user=root --mysql-password=your_password --threads=4 --time=60 run

Running a Read-Only Test:

sysbench oltp_read_only --table-size=1000000 --db-driver=mysql --mysql-host=localhost --mysql-db=sysbench_test --mysql-user=root --mysql-password=your_password --threads=4 --time=60 run

Important Database Test Parameters:

  • --table-size: Number of rows in test tables
  • --threads: Number of client connections to use
  • --time: Test execution time
  • --report-interval: Periodically report intermediate statistics
  • --db-ps-mode: Prepared statement usage mode (auto, disable)

Cleaning Up After Tests:

sysbench oltp_read_write --db-driver=mysql --mysql-host=localhost --mysql-db=sysbench_test --mysql-user=root --mysql-password=your_password cleanup

Advanced Sysbench Usage

Once you’re comfortable with basic Sysbench operations, you can explore more advanced usage scenarios for comprehensive system evaluation.

Creating Custom Benchmark Scripts:

Sysbench uses Lua for custom benchmarking scripts. Create a file named custom_test.lua with contents:

function event()
  -- Your custom benchmark logic here
  -- For example, this performs some CPU work:
  local a = 0
  for i = 1, 10000 do
    a = a + i
  end
  return 0
end

function prepare()
  -- Preparation logic (if needed)
end

function cleanup()
  -- Cleanup logic (if needed)
end

Run your custom script:

sysbench custom_test.lua run

Combining Different Test Types:

You can run multiple tests in sequence using shell scripts:

#!/bin/bash
# Run CPU, memory, and fileio tests in sequence

echo "Running CPU test..."
sysbench cpu --cpu-max-prime=20000 run > cpu_results.txt

echo "Running memory test..."
sysbench memory --memory-total-size=5G run > memory_results.txt

echo "Preparing file I/O test..."
sysbench fileio --file-total-size=2G prepare

echo "Running file I/O test..."
sysbench fileio --file-total-size=2G --file-test-mode=rndrw run > fileio_results.txt

echo "Cleaning up file I/O test..."
sysbench fileio --file-total-size=2G cleanup

echo "All tests completed. Results saved to *_results.txt files."

Scheduling Regular Benchmarks:

Set up cron jobs to run benchmarks automatically:

# Edit crontab
crontab -e

# Add this line to run a benchmark every Sunday at 2 AM
0 2 * * 0 /home/user/scripts/weekly_benchmark.sh >> /home/user/benchmark_logs/weekly.log 2>&1

Exporting and Visualizing Results:

You can use the --report-interval option to generate data points over time:

sysbench cpu --cpu-max-prime=20000 --report-interval=5 run > results.csv

Then process the output with tools like GNU Plot, Python’s matplotlib, or import into spreadsheet software for visualization.

Troubleshooting Common Issues

Even with careful installation, you may encounter issues with Sysbench. Here are solutions to common problems:

Missing Library Dependencies:

If you see errors like:

./sysbench: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

Install the missing library:

sudo zypper install libmysqlclient20

Or for other missing libraries, use:

sudo zypper search libname
sudo zypper install package-with-library

Permission Issues:

If you encounter permission errors during file I/O or database tests:

  1. For file I/O tests, ensure you have write permissions in the current directory:
    sudo chmod 755 /path/to/test/directory
  2. For database tests, verify the database user has proper permissions:
    mysql -u root -p -e "GRANT ALL PRIVILEGES ON sysbench_test.* TO 'user'@'localhost';"

Resource Constraints:

If Sysbench terminates abruptly due to resource limitations:

  1. Check system resources:
    free -h
    df -h
  2. Adjust test parameters to use fewer resources:
    sysbench --threads=2 --memory-total-size=1G memory run
  3. For large tests, increase system limits in /etc/security/limits.conf.

Incompatible Versions:

If you experience compatibility issues between Sysbench and openSUSE:

  1. Check your Sysbench version:
    sysbench --version
  2. Consider installing a different version through an alternative repository or compiling from source with specific version tags.

Performance Optimization Based on Benchmark Results

After running Sysbench benchmarks, you can use the results to optimize your system:

CPU Optimization:

If CPU tests show lower than expected performance:

  1. Check for CPU throttling:
    grep "cpu MHz" /proc/cpuinfo
  2. Adjust CPU governor:
    sudo cpupower frequency-set -g performance
  3. Monitor temperature during benchmarks:
    sensors
  4. Consider BIOS updates or CPU cooling improvements if thermal throttling occurs.

Memory Optimization:

If memory tests reveal suboptimal performance:

  1. Check if dual-channel memory is properly configured
  2. Verify memory frequency settings in BIOS
  3. Consider enabling XMP profiles for supported memory
  4. Adjust swappiness if swap usage impacts performance:
    sudo sysctl vm.swappiness=10

Storage Optimization:

For improving I/O performance based on benchmarks:

  1. For mechanical drives, consider enabling drive caching:
    sudo hdparm -W1 /dev/sda
  2. For SSDs, enable TRIM:
    sudo systemctl enable fstrim.timer
  3. Adjust the I/O scheduler based on your storage type:
    echo "noop" | sudo tee /sys/block/sda/queue/scheduler  # For SSDs
    echo "bfq" | sudo tee /sys/block/sda/queue/scheduler   # For HDDs
  4. Consider filesystem optimization parameters in /etc/fstab.

Updating and Maintaining Sysbench

Keeping Sysbench updated ensures you have access to the latest features and bug fixes:

Checking for Updates:

For repository installations:

sudo zypper refresh
sudo zypper update sysbench

For source installations, check for new releases:

cd /path/to/sysbench/source
git fetch
git checkout v1.0.20  # Replace with latest version
./autogen.sh
./configure
make -j $(nproc)
sudo make install

Managing Multiple Versions:

If you need multiple Sysbench versions for compatibility testing:

  1. Install different versions to separate directories:
    ./configure --prefix=/opt/sysbench-1.0.20
    make -j $(nproc)
    sudo make install
  2. Create symbolic links or aliases to select the version:
    alias sysbench-1.0.20="/opt/sysbench-1.0.20/bin/sysbench"

Removing Sysbench:

If you need to uninstall Sysbench:

For repository installations:

sudo zypper remove sysbench

For source installations:

cd /path/to/sysbench/source
sudo make uninstall

Congratulations! You have successfully installed Sysbench. Thanks for using this tutorial to install the latest version of the Sysbench benchmark tool on openSUSE Linux system. For additional help or useful information, we recommend you check the official Sysbench website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button