sysbench是一款压力测试工具,可以测试系统的硬件性能,也可以用来对数据库进行基准测试。
安装方式:https://github.com/akopytov/sysbench/blob/master/README.md#general-command-line-options
此处安装的是sysbench 1.0.6版本,和网上大部分的0.4,0.5版本的命令不太一样。
sysbench支持三种测试方案:
1、使用自带的测试模块,如对cpu,I/O,memory等的测试。
2、使用自带的lua脚本进行测试,如果使用快速安装的方式,默认的脚本路径为:/usr/share/sysbench
3、使用自定义的lua脚本。
获取帮助信息:
如果对相关模块或者脚本的参数不明确的,可以使用 sysbench testname help来查看,testname含模块名称和脚本名称。sysbench经典测试命令:
prepare: 创建测试数据或者相关的测试文件,为测试做准备工作。如数据库的测试数据准备等。
run: 开始执行测试。
cleanup: 移除测试数据
help: 帮助命令
测试CPU性能
sysbench cpu --cpu-max-prime=10000 run
#显示测试结果
General statistics:
total time: 10.0003s
total number of events: 8692
Latency (ms):
min: 1.12
avg: 1.15
max: 2.98
95th percentile: 1.25
sum: 9996.64
Threads fairness:
events (avg/stddev): 8692.0000/0.00
execution time (avg/stddev): 9.9966/0.00
I/O测试
准备测试数据:
sysbench fileio --file-total-size=40G prepare
运行顺序写入测试:
sysbench fileio --file-total-size=40G --file-test-mode=seqwr run
#测试结果
File operations:
reads/s: 0.00
writes/s: 3916.87
fsyncs/s: 5001.01
Throughput:
read, MiB/s: 0.00
written, MiB/s: 61.20
General statistics:
total time: 10.0055s
total number of events: 89250
Latency (ms):
min: 0.01
avg: 0.11
max: 28.02
95th percentile: 0.12
sum: 9937.24
Threads fairness:
events (avg/stddev): 89250.0000/0.00
execution time (avg/stddev): 9.9372/0.00
运行顺序重写测试:
sysbench fileio --file-total-size=40G --file-test-mode=seqrewr run
#测试结果:
File operations:
reads/s: 0.00
writes/s: 4018.65
fsyncs/s: 5131.38
Throughput:
read, MiB/s: 0.00
written, MiB/s: 62.79
General statistics:
total time: 10.0003s
total number of events: 91531
Latency (ms):
min: 0.00
avg: 0.11
max: 31.45
95th percentile: 0.10
sum: 9933.80
Threads fairness:
events (avg/stddev): 91531.0000/0.00
execution time (avg/stddev): 9.9338/0.00