|
|
# sysbench --mysql-host=192.168.10.226 --mysql-port=3306 --mysql-user=root \$ [! d7 E& D; e& _( D
--mysql-password=Changeme_123 --test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=10 \
( n/ H0 e ~* x( l--oltp-table-size=10000000 --num-threads=8 --oltp-read-only=off --db-driver=mysql \
+ h9 u) e' p2 l( U* E" S--report-interval=10 --rand-type=uniform --max-time=3600 \
" V- r9 ]) M( ]" p1 O! Z0 l2 d --max-requests=0 --percentile=99 run >> mysql.log" C/ a: c+ a7 `5 T/ O
P7 s6 I; r# b* _3 G1 c
参数说明 . f9 \" B) \5 }! v9 I$ E$ ^! }
–num-threads=8 表示发起 8个并发连接" Z( q6 E, l7 @$ e& ^' q
0 w; _1 M9 _$ t2 G, ^
–oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试
4 q) Y# ~+ p' j ] P3 U
4 {% k* o: W8 c2 P5 q# z6 _–report-interval=10 表示每10秒输出一次测试进度报告
8 p1 o$ N: G1 g9 v* d, N
9 U& t6 m& ~3 P8 o" q# E: ?–rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托): Y @' o' s; G5 m, y
* q0 @4 _# r4 L3 q' X
–max-time=120 表示最大执行时长为 120秒
$ Q m* j6 t- J5 ?7 @
& ~8 E* s! V( d% s1 ^' S–max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长/ v {' \- w$ |1 P. m) |0 k- ]
g3 s" \/ L- i–percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值& R) N5 W/ I2 U
4 |1 b+ ]- Z; l4 S7 H& v. d% d即:模拟 对10个表并发OLTP测试,每个表1000万行记录,持续压测时间为 1小时。
^/ G9 p7 ~0 U; P: h0 u. m9 x真实测试场景中,建议持续压测时长不小于30分钟,否则测试数据可能不具参考意义。# v4 X% {8 P6 i2 [; r( p# I; S
( M3 k1 h1 s; @, i- b- h7 C# Ysysbench 0.5: multi-threaded system evaluation benchmark
0 R' B" \+ ?, h% p5 a
: ~5 B. @3 ^+ ^& [! KRunning the test with following options:
a$ U0 E' n _4 C2 e( GNumber of threads: 8
) g l4 ~8 D5 p3 b* TReport intermediate results every 10 second(s)* M7 E+ Y/ A" i
Random number generator seed is 0 and will be ignored
/ x y/ W2 J% U8 @% @6 Z/ d/ Q! ~% s' p6 u$ N9 S( s. Z* `. y( a
; \, L8 P U, _! ?) C. a
Threads started!! }( a0 m7 i9 m4 Q' A0 h- [
-- 每10秒钟报告一次测试结果,tps、每秒读、每秒写、99%以上的响应时长统计
+ S2 n- ~$ y4 O" l7 q[ 10s] threads: 8, tps: 1111.51, reads/s: 15568.42, writes/s: 4446.13, response time: 9.95ms (99%)
- N3 h! N2 v! P- v[ 20s] threads: 8, tps: 1121.90, reads/s: 15709.62, writes/s: 4487.80, response time: 9.78ms (99%)! p7 c0 _$ z# u q6 U
[ 30s] threads: 8, tps: 1120.00, reads/s: 15679.10, writes/s: 4480.20, response time: 9.84ms (99%)
& g. K9 M; S5 S/ f[ 40s] threads: 8, tps: 1114.20, reads/s: 15599.39, writes/s: 4456.30, response time: 9.90ms (99%)
0 t! P9 @- S0 h0 g[ 50s] threads: 8, tps: 1114.00, reads/s: 15593.60, writes/s: 4456.70, response time: 9.84ms (99%)
3 F* v) r& j1 p) E[ 60s] threads: 8, tps: 1119.30, reads/s: 15671.60, writes/s: 4476.50, response time: 9.99ms (99%). ~7 L8 C) {2 P" n+ P0 D
OLTP test statistics:
! T7 W/ o. e$ J queries performed:+ h. D- g) U) w
read: 938224 -- 读总数: x' [- W% s* V5 _4 V$ l
write: 268064 -- 写总数- v8 }, e8 q( R8 e V
other: 134032 -- 其他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)) D7 ~8 ?2 T! p0 U* ~# e
total: 1340320 -- 全部总数
/ ]! h- q& F4 E0 \. N' d7 A transactions: 67016 (1116.83 per sec.) -- 总事务数(每秒事务数)
- g& z' C% Z: e _+ |: b& K deadlocks: 0 (0.00 per sec.) -- 发生死锁总数; L& h2 |2 `9 V8 x
read/write requests: 1206288 (20103.01 per sec.) -- 读写总数(每秒读写次数)$ R/ C) h$ h+ Y' B" J' N3 o9 ~% ^
other operations: 134032 (2233.67 per sec.) -- 其他操作总数(每秒其他操作次数)
w7 C; h7 g# ^7 i9 Z0 p8 q5 f% Y2 X* b& v
General statistics: -- 一些统计结果
8 D7 o5 t% I7 |( |8 ]) N total time: 60.0053s -- 总耗时 m) k2 C. U8 q1 ~4 \
total number of events: 67016 -- 共发生多少事务数- o5 N: Y0 B: x6 ^& H
total time taken by event execution: 479.8171s -- 所有事务耗时相加(不考虑并行因素)4 K, T0 Q. u% B$ G$ w1 m" i% n
response time: -- 响应时长统计2 q+ I& d( O( ?% x; v3 K
min: 4.27ms -- 最小耗时
* b, c* `8 u5 T" D$ U/ a2 ` avg: 7.16ms -- 平均耗时1 W) R2 O7 n9 d% E2 B7 _$ S0 K
max: 13.80ms -- 最长耗时1 q4 N L$ s* C: P+ ]
approx. 99 percentile: 9.88ms -- 超过99%平均耗时
5 A1 X) b+ M, N
$ p% A/ Z# S% m \8 xThreads fairness:
6 ]. s4 c" n$ ^7 m5 J events (avg/stddev): 8377.0000/44.33
) c6 _8 [$ i( v. T: \, D+ S* B& ~ execution time (avg/stddev): 59.9771/0.00
+ v* J9 V) x$ {4 |& T) {. N, n' i6 @& K+ ^0 u# L; S [6 V
' d0 {9 }1 l- W* O) q
最重要的参数指标:1 y/ y6 K9 I1 n
总的事物数,每秒事务数,时间统计信息(最大、最小、平均、95%以上语句响应时间)
4 M- r" y- j/ t4 n删除数据
% R& r/ W- {3 L" g3 }* a! |+ g2 ~$ E
sysbench --mysql-host=192.168.10.226 --mysql-port=3306 --mysql-user=root --mysql-password=Changeme_123 --db-driver=mysql \# `' d% [0 g {8 @4 s, B
--test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=10 --oltp-table-size=100000 --rand-init=on cleanup
5 v! C! Y- U& f! ^+ p" A
( T9 K3 y/ m- k( ^7 F |
|