一般在怀疑硬件问题或者做benchmark时可以使用该工具,此笔记用于benchmark0.5版本
IO测试
准备测试文件sysbench --test=fileio --file-num=16 --file-total-size=2G prepare
执行IO测试
sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrd --max-time=180 --max-requests=100000000 --num-threads=16 --init-rng=on --file-num=16 --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 run
关注点:
1、Total transferred 459.61Mb (2.5522Mb/sec),正常值应50M以上
2、163.34 Requests/sec executed 随机读的IOPS。正常值4000以上
清理测试文件
sysbench --test=fileio --file-num=16 --file-total-size=2G cleanup
测试MYSQL OLTP
首先创建测试数据库,执行数据准备
sysbench --test=oltp --mysql-host=192.168.10.119 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=sysbenchtest --oltp-tables-count=10 --oltp-table-size=6000000 --num-threads=50 --max-requests=100000000 --report-interval=1 --test=/tmp/sysbench-0.5/sysbench/tests/db/oltp.lua prepare
执行压测
sysbench --test=oltp --mysql-host=192.168.10.119 --oltp-test-mode=simeple --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=sysbenchtest --oltp-tables-count=10 --oltp-table-size=6000000 --num-threads=50 --max-requests=100000000 --report-interval=1 --max-time=20 --test=/tmp/sysbench-0.5/sysbench/tests/db/oltp.lua run
纯insert测试
sysbench --test=oltp --mysql-host=192.168.10.119 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=sysbenchtest --oltp-tables-count=10 --oltp-table-size=600000 --num-threads=50 --max-requests=100000000 --report-interval=1 --max-time=20 --test=/tmp/sysbench-0.5/sysbench/tests/db/oltp.lua run
sysbench --test=oltp --mysql-table-engine=innodb --mysql-user=root --mysql-password=123456 --db-driver=mysql --oltp-nontrx-mode=update_key --mysql-db=sysbenchtest --oltp-table-size=600000 --oltp-table-name=sbtest10 --test=/tmp/sysbench-0.5/sysbench/tests/db/oltp.lua run
针对CPU进行测试
指定最大的素数
sysbench --test=cpu --cpu-max-prime=20000 run
cpu测试主要是寻找素数的方式
针对线程处理能力测试
sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run
--thread-yields=N 指定每个请求的压力,默认为1000
--thread-locks=N 指定每个线程的锁数量,默认为8
互斥锁测试
sysbench --test=mutex --num-threads=16 \--mutex-num=1024 --mutex-locks=10000 --mutex-loops=5000 run
--mutex-num=N 数组互斥的总大小。默认是4096
--mutex-locks=N 每个线程互斥锁的数量。默认是50000
--mutex-loops=N 内部互斥锁的空循环数量。默认是10000
内存测试
sysbench --test=memory --num-threads=512 --memory-block-size=262144 --memory-total-size=32G run