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


# sysbench --file-total-size=28G --test=fileio prepare
# sysbench --file-total-size=28G --file-test-mode=rndrw --time=300 --max-requests=0 --test=fileio run
# sysbench --file-total-size=28G fileio cleanup
对于 I/O 基准测试 , 可以通过 --file-test-mode 告诉 sysbench 要运行的工作负载的类型 , 可用类型有:
seqwr:顺序写入
seqrewr:顺序重写
seqrd:顺序读取
rndrd:随机读取
rndwr:随机写入
rndrw:随机读取/写入
上面的例子中使用的是随机读取/写入(rndrw) 。通过 --time 选项指定测试持续时间(以秒为单位) 。
帮助信息:
# 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]
命令的完整输出如下:
[root@VM_157_18_centos ~]# sysbench --file-total-size=28G fileio prepare
sysbench 1.0.9 (using system LuaJIT 2.0.4)
128 files, 229376Kb each, 28672Mb total
Creating files for the test...
Extra file open flags: 0
Creating file test_file.0
Creating file test_file.1
...此处总共创建了 128 个文件 , 每个 229376Kb , 总共 28672Mb
Creating file test_file.127
30064771072 bytes written in 255.52 seconds (112.21 MiB/sec).
[root@VM_157_18_centos ~]# sysbench --file-total-size=28G --file-test-mode=rndrw --time=300 --max-requests=0 fileio run
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Extra file open flags: 0
128 files, 224MiB each
28GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...
Threads started!
File operations:
reads/s: 96.00
writes/s: 64.00
fsyncs/s: 204.47
Throughput:
read, MiB/s: 1.50
written, MiB/s: 1.00
General statistics:
total time: 300.0016s
total number of events: 109341
Latency (ms):
min: 0.00
avg: 2.74
max: 256.76
95th percentile: 7.17
sum: 299726.28
Threads fairness:
events (avg/stddev): 109341.0000/0.00
execution time (avg/stddev): 299.7263/0.00
[root@VM_157_18_centos ~]# sysbench --file-total-size=28G fileio cleanup
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Removing test files...
2.4 测试 memory
当在 sysbench 中进行内存测试时 , 会分配一个内存缓冲区并在此执行读写操作 , 每次操作都会读完或写满缓冲区 。然后重复此操作直到达到指定大小(--memory-total-size) 。可以提供多个线程(--threads) , 不同的缓冲区大小(--memory-block-size)和请求类型(读或写 , 顺序或随机) 。
帮助信息:
# sysbench memory help
sysbench 1.0.9 (using system LuaJIT 2.0.4)
memory options:
--memory-block-size=SIZE size of memory block for test [1K]
--memory-total-size=SIZE total size of data to transfer [100G]
--memory-scope=STRING memory access scope {global,local} [global]
--memory-hugetlb[=on|off] allocate memory from HugeTLB pool [off]
--memory-oper=STRING type of memory operations {read, write, none} [write]
--memory-access-mode=STRING memory access mode {seq,rnd} [seq]
例如 , 指定 4 个线程 , 缓冲区大小为 8KB , 在内存中传输 4GB 数据的测试:
[root@VM_157_18_centos ~]# sysbench --threads=4 --memory-block-size=8k --memory-total-size=4G memory run


推荐阅读