mysql压力测试-sysbench安装及使用说明( 二 )


--histogram[=on|off] print latency histogram in report [off]
General database options: # 通用的数据库选项
--db-driver=STRING 指定要使用的数据库驱动程序 ('help' to get list of available drivers)
--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
--db-debug[=on|off] print database-specific debug information [off]
Compiled-in database drivers: # 內建的数据库驱动程序 , 默认支持 MySQL 和
PostgreSQL
mysql - MySQL driver
pgsql - PostgreSQL driver
mysql options: # MySQL 数据库专用选项
--mysql-host=[LIST,...] MySQL server host [localhost]
--mysql-port=[LIST,...] MySQL server port [3306]
--mysql-socket=[LIST,...] MySQL socket
--mysql-user=STRING MySQL user [sbtest]
--mysql-password=STRING MySQL password []
--mysql-db=STRING MySQL database name [sbtest]
--mysql-ssl[=on|off] use SSL connections, if available in the client library [off]
--mysql-ssl-cipher=STRING use specific cipher for SSL connections []
--mysql-compression[=on|off] use compression, if available in the client library [off]
--mysql-debug[=on|off] trace all client library calls [off]
--mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]
--mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off]
pgsql options: # PostgreSQL 数据库专用选项
--pgsql-host=STRING PostgreSQL server host [localhost]
--pgsql-port=N PostgreSQL server port [5432]
--pgsql-user=STRING PostgreSQL user [sbtest]
--pgsql-password=STRING PostgreSQL password []
--pgsql-db=STRING PostgreSQL database name [sbtest]
Compiled-in tests: # 內建测试类型
fileio - File I/O test
cpu - CPU performance test
memory - Memory functions speed test
threads - Threads subsystem performance test
mutex - Mutex performance test
See 'sysbench <testname> help' for a list of options for each test.
sysbench <testname> help
通过 sysbench <testname> help 命令可以查看具体一个测试类型的帮助信息 。
# sysbench fileio --help
sysbench 1.0.9 (using system LuaJIT 2.0.4)
fileio options:
--file-num=N number of files to create [128]
--file-block-size=N block size to use in all IO operations [16384]
--file-total-size=SIZE total size of files to create [2G]
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync]
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all[=on|off] do fsync() after each write operation [off]
--file-fsync-end[=on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5]
3.2 测试 CPU
CPU 测试时 , 会计算素数(对这个数字除以 2 到这个数字平方根之间的所有数字来验证素数)直到某个指定值所需要的时间 。单纯的测试一组非常有限 CPU 硬件性能 。
CPU 基准测试时可以指定线程数量和素数上限 。
先查看帮助信息:
[root@VM_157_18_centos ~]# sysbench cpu help
sysbench 1.0.9 (using system LuaJIT 2.0.4)
cpu options:
--cpu-max-prime=N 素数发生器的上限(upper limit for primes generator) [10000]
开始测试:
[root@VM_157_18_centos ~]# sysbench --cpu-max-prime=10000 --threads=2 cpu run
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 2
Initializing random number generator from current time
Prime numbers limit: 10000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 727.23
【mysql压力测试-sysbench安装及使用说明】General statistics:
total time: 10.0020s
total number of events: 7275
Latency (ms):
min: 1.34
avg: 2.75
max: 39.37
95th percentile: 12.30
sum: 19982.10
Threads fairness:
events (avg/stddev): 3637.5000/1.50
execution time (avg/stddev): 9.9911/0.00
3.3 测试 fileio
使用 fileio 时 , 需要创建一组测试文件 , 测试文件需要大于可用内存的大小 , 避免文件缓存在内存中影响结果 。测试流程为:准备测试文件-》测试-》回收测试文件 , 命令如下:


推荐阅读