sysbench的安装和做性能测试
一、安装# 下载源码包,按以下步骤安装二、测试
# https://launchpad.net/ubuntu/utopic/+source/sysbench 下载源码包
tar zxf sysbench-0.4.12.tar.gz
cd sysbench-0.4.12
# 配置。mysql的安装路径 /usr/local/mysql/
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
# 编译
make错误1:X--tag=CC: command not found解决办法:vim libtool(当前目录下)# An echo program that does not interpret backslashes.#ECHO="echo"替换为echo="echo"http://blog.itpub.net/26250550/viewspace-1682634/
# 安装
make install
每种测试模式的详细参数
mode:fileio,cpu,memory,threads,mutex,oltp
sysbench --test=
--num-threads=N,是每种测试都需要设置的
fileio
sysbench --num-threads=N --test=fileio --file-test-mode=
--num-threads=N,根据数据库的IO线程数(读写各4个,purge1个,主线程)+max_user_connections(不确定是否加这个,理论上应该不加)
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
oltp使用rndrw; olap 使用seqrd; 日志:使用seqwr;
sysbench --num-threads=10 --test=fileio --file-test-mode=rndrw prepare
sysbench --num-threads=10 --test=fileio --file-test-mode=rndrw run
sysbench --num-threads=10 --test=fileio --file-test-mode=rndrw cleanup
点击(此处)折叠或打开
-
Operations performed: 6005 Read, 3998 Write, 12807 Other = 22810 Total
-
Read 93.828Mb Written 62.469Mb Total transferred 156.3Mb (2.8269Mb/sec)
-
180.92 Requests/sec executed
-
-
Test execution summary:
-
total time: 55.2882s
-
total number of events: 10003
-
total time taken by event execution: 116.1046
-
per-request statistics:
-
min: 0.01ms
-
avg: 11.61ms
-
max: 127.19ms
-
approx. 95 percentile: 45.21ms
-
-
Threads fairness:
-
events (avg/stddev): 1000.3000/50.58
- execution time (avg/stddev): 11.6105/0.22
cpu
sysbench --num-threads=500 --test=cpu run
--num-threads=N,根据max_user_connections
点击(此处)折叠或打开
-
Test execution summary:
-
total time: 2.7773s
-
total number of events: 10000
-
total time taken by event execution: 929.5525
-
per-request statistics:
-
min: 1.10ms
-
avg: 92.96ms
-
max: 1990.11ms
-
approx. 95 percentile: 524.92ms
-
-
Threads fairness:
-
events (avg/stddev): 20.0000/15.88
- execution time (avg/stddev): 1.8591/0.52
memory
sysbench --num-threads=500 --test=memory --memory-block-size=16K run
--num-threads=N,根据max_user_connections
--memory-block-size= 16K, 与页大小一致
--memory-oper=write|read,测试不同模式下的速度
点击(此处)折叠或打开
-
Operations performed: 6553600 (144538.32 ops/sec)
-
-
102400.00 MB transferred (2258.41 MB/sec)
-
-
-
Test execution summary:
-
total time: 45.3416s
-
total number of events: 6553600
-
total time taken by event execution: 17959.0829
-
per-request statistics:
-
min: 0.00ms
-
avg: 2.74ms
-
max: 1360.60ms
-
approx. 95 percentile: 0.03ms
-
-
Threads fairness:
-
events (avg/stddev): 13107.2000/394.74
- execution time (avg/stddev): 35.9182/0.88
mutex
sysbench --num-threads=500 --test=mutex run
--num-threads=N,根据max_user_connections
点击(此处)折叠或打开
-
Test execution summary:
-
total time: 4.3611s
-
total number of events: 100
-
total time taken by event execution: 432.1235
-
per-request statistics:
-
min: 4148.02ms
-
avg: 4321.24ms
-
max: 4356.73ms
-
approx. 95 percentile: 4350.67ms
-
-
Threads fairness:
-
events (avg/stddev): 1.0000/0.00
- execution time (avg/stddev): 4.3212/0.03
threads
sysbench --num-threads=500 --test=threads run
点击(此处)折叠或打开
-
Test execution summary:
-
total time: 3.3147s
-
total number of events: 10000
-
total time taken by event execution: 329.1616
-
per-request statistics:
-
min: 0.53ms
-
avg: 32.92ms
-
max: 228.56ms
-
approx. 95 percentile: 85.67ms
-
-
Threads fairness:
-
events (avg/stddev): 100.0000/4.70
- execution time (avg/stddev): 3.2916/0.01
oltp
1:oltp: 500线程,innodb表,最大100W行数据
sysbench --num-threads=500 --test=oltp --oltp-test-mode=complex --mysql-host=localhost --mysql-user=sbtest --mysql-password=sbtest --mysql-db=test_sb --oltp-table-size=1000000 prepare
--num-threads=N,根据max_user_connections
--oltp-test-mode=complex,使用混合测试
sysbench --num-threads=500 --test=oltp --oltp-test-mode=complex --mysql-host=localhost --mysql-user=sbtest --mysql-password=sbtest --mysql-db=test_sb --oltp-table-size=1000000 run
sysbench --num-threads=500 --test=oltp --oltp-test-mode=complex --mysql-host=localhost --mysql-user=sbtest --mysql-password=sbtest --mysql-db=test_sb --oltp-table-size=1000000 cleanup
点击(此处)折叠或打开
- OLTP test statistics:
- queries performed:
- read: 145194
- write: 50922
- other: 20374
- total: 216490
- transactions: 10003 (372.70 per sec.)
- deadlocks: 368 (13.71 per sec.)
- read/write requests: 196116 (7307.05 per sec.)
- other operations: 20374 (759.11 per sec.)
- Test execution summary:
- total time: 26.8393s
- total number of events: 10003
- total time taken by event execution: 2679.0895
- per-request statistics:
- min: 40.40ms
- avg: 267.83ms
- max: 1712.27ms
- approx. 95 percentile: 566.22ms
- Threads fairness:
- events (avg/stddev): 100.0300/4.68
- execution time (avg/stddev): 26.7909/0.03