MySQL基准测试工具

环境:CentOS6.5,MySQL5.7.22
1.下载 sysbench下载地址
2.安装

tar -zxvf sysbench-1.1.0.tar.gz
yum install automake libtool –y  #安装依赖包
cd sysbench-0.4.12.14
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib --with-mysql
export LD_LIBRARY_PATH=/usr/local/mysql/include #这里换成机器中mysql路径下的include
make
make install
sysbench --version  # 检验安装是否成功

3.简介
sysbench是跨平台的基准测试工具,支持多线程,支持多种数据库,主要包括以下几种测试:
•CPU性能
•磁盘io性能
•调度程序性能
•内存分配及传输速度
•POSIX线程性能
•数据库性能(基于OLTP的基本测试)

4.sysbench语法 sysbench [options] [testname] [command]
•command sysbench要执行的命令,包括prepare,run,cleanup。
•testname 指定要进行的测试

•options
◦--mysql-host MySQL服务器主机名
◦--mysql-port MySQL服务器端口,默认为3306
◦--mysql-user MySQL用户名
◦--mysql-password MySQL密码
◦--oltp-test-mode 执行模式,默认为complex
◦--oltp-tables-size 测试表的大小
◦--oltp-tables-count 测试表的数量
◦--threads 客户端的并发连接
◦--time 测试执行的时间
5.测试实例

•CPU测试 ◦--cpu-max-prime=N upper limit for primes generator [10000]
sysbench    --cpu-max-prime=20000 --report-interval=10


•fileio测试
*4个线程,随机读写,每10s输出一次结果
[root@slave1 sysbench-master]# sysbench fileio  help
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
fileio options:
--file-num=N                  number of files to create [128]  #需要创建的文件数,默认为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] # 文件操作模式{sync(同步),async(异步),fastmmap(快速map映射),slowmmap(慢map映射)}。默认是sync
--file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
--file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []  #使用额外的标志来打开文件{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]  #使用哪种方法进行同步{fsync, fdatasync}。默认是fsync
--file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0] #如果可以,合并最多的IO请求数(0–表示不合并)。默认是0
--file-rw-ratio=N            reads/writes ratio for combined test [1.5] #测试时的读写比例。默认是1.5


[root@slave1 sysbench-master]# sysbench --threads=4 --file-test-mode=rndwr --report-interval=10 fileio prepare  #准备阶段
[root@slave1 sysbench-master]# sysbench --threads=4 --time=60 --report-interval=10 --file-test-mode=rndrw fileio run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Report intermediate results every 10 second(s)
Initializing random number generator from current time

Extra file open flags: (none)
128 files, 16MiB each
2GiB 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!

[ 10s ] reads: 3.65 MiB/s writes: 2.44 MiB/s fsyncs: 494.49/s latency (ms,95%): 30.265
[ 20s ] reads: 3.00 MiB/s writes: 2.00 MiB/s fsyncs: 412.60/s latency (ms,95%): 34.954
[ 30s ] reads: 3.28 MiB/s writes: 2.19 MiB/s fsyncs: 444.19/s latency (ms,95%): 35.589
[ 40s ] reads: 3.19 MiB/s writes: 2.13 MiB/s fsyncs: 434.41/s latency (ms,95%): 38.247
[ 50s ] reads: 3.00 MiB/s writes: 2.00 MiB/s fsyncs: 410.90/s latency (ms,95%): 37.565
[ 60s ] reads: 3.09 MiB/s writes: 2.06 MiB/s fsyncs: 419.19/s latency (ms,95%): 35.589

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/277b3b6be3ed60d6653c4bd9c937704e.html