yum -y install sysbench
echo "* hard nofile 65535
* soft nofile 65535
">>/etc/security/limits.conf
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 63389
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 63389
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
sysbench –version
sysbench fileio –file-num=10 –file-total-size=50G prepare
sysbench 1.0.17 (using system LuaJIT 2.0.4)
10 files, 1048576Kb each, 10240Mb total
Creating files for the test…
Extra file open flags: (none)
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
Creating file test_file.4
Creating file test_file.5
Creating file test_file.6
Creating file test_file.7
Creating file test_file.8
Creating file test_file.9
10737418240 bytes written in 83.49 seconds (122.65 MiB/sec).
#This gives a sequential write throughput of 122.65MB/s, representing the disk’s throughput.
Generally, sequential read/write is referred to as throughput, while random I/O is measured in IOPS.
ll -h
total 10G
-rw——-. 1 root root 1.0G May 26 18:00 test_file.0
-rw——-. 1 root root 1.0G May 26 18:00 test_file.1
-rw——-. 1 root root 1.0G May 26 18:01 test_file.2
-rw——-. 1 root root 1.0G May 26 18:01 test_file.3
-rw——-. 1 root root 1.0G May 26 18:01 test_file.4
-rw——-. 1 root root 1.0G May 26 18:01 test_file.5
-rw——-. 1 root root 1.0G May 26 18:01 test_file.6
-rw——-. 1 root root 1.0G May 26 18:01 test_file.7
-rw——-. 1 root root 1.0G May 26 18:01 test_file.8
-rw——-. 1 root root 1.0G May 26 18:01 test_file.9
After the data is prepared, run the test:
Here is a random read/write test:
sysbench fileio –file-num=10 –file-total-size=10G –file-block-size=16384 –file-test-mode=rndrw –file-io-mode=sync –file-extra-flags=direct –time=100 –threads=16 –report-interval=10 run
Sequential read test:
sysbench fileio –file-num=10 –file-total-size=10G –file-block-size=16384 –file-test-mode=seqrd –file-io-mode=sync –file-extra-flags=direct –time=100 –threads=16 –report-interval=10 run
After the test phase is complete, run the final cleanup:
sysbench fileio –file-num=10 –file-total-size=10 cleanup
mysql -uroot -p
create database sbtest; #Create database

Prepare the data. This takes a long time; you can set table_size smaller:
sysbench /usr/share/sysbench/oltp_read_write.lua –tables=3 –table_size=10000000 –mysql-user=root –mysql-password=Qian123# –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-db=sbtest prepare
Check the data in the MySQL shell:
mysql> select count(*) from sbtest1;
mysql> show tables;
sysbench /usr/share/sysbench/oltp_point_select.lua –tables=3 –table_size=10000000 –mysql-user=root –mysql-password=Qian123# –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-db=sbtest –threads=1280 –time=100 –report-interval=5 run
min #Minimum response time
avg #Average response time
max #Maximum response time
95th percentile #95% of response times are below this value
–threads=N #Specifies the number of threads for the test, default is 1
TPS and QPS are basically equal, indicating that one query in this lua script generally equals one transaction!
Clean up the data:
sysbench /usr/share/sysbench/oltp_read_write.lua –tables=3 –table_size=10000000 –mysql-user=root –mysql-password=Qian123# –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-db=sbtest cleanup
Prepare benchmark data:
sysbench /usr/share/sysbench/oltp_insert.lua –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=root –mysql-password='Qian123#' –mysql-db=sbtest –db-driver=mysql –tables=15 –table-size=500000 –report-interval=10 –threads=3000 –time=120 prepare
Run benchmark
sysbench /usr/share/sysbench/oltp_insert.lua –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=root –mysql-password='Qian123#' –mysql-db=sbtest –db-driver=mysql –tables=15 –table-size=500000 –report-interval=10 –threads=3000 –time=120 run
Export test results to a file for later analysis:
sysbench /usr/share/sysbench/oltp_insert.lua –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=root –mysql-password='Qian123#' –mysql-db=sbtest –db-driver=mysql –tables=15 –table-size=500000 –report-interval=10 –threads=3000 –time=120 run >> ./mysysbench.log