你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

MySQL 官方压测工具

[复制链接]
gaosmile 发布时间:2021-2-3 12:40
一、MySQL自带的压力测试工具 Mysqlslap
mysqlslap是mysql自带的基准测试工具,该工具查询数据,语法简单,灵活容易使用.该工具可以模拟多个客户端同时并发的向服务器发出查询更新,给出了性能测试数据而且提供了多种引擎的性能比较。mysqlslap为mysql性能优化前后提供了直观的验证依据,系统运维和DBA人员应该掌握一些常见的压力测试工具,才能准确的掌握线上数据库支撑的用户流量上限及其抗压性等问题。
1、更改其默认的最大连接数
在对MySQL进行压力测试之前,需要更改其默认的最大连接数,如下:
[root@mysql ~]# vim /etc/my.cnf
1 k6 l* L  A. K! X+ H! J................4 R+ C% G; V2 a+ _! I9 m
[mysqld]
  ]% ^, M5 r3 lmax_connections=1024
7 m& O. j6 M$ e
# ~1 j$ c" @( D; B' S[root@mysql ~]# systemctl restart mysqld
0 N2 q1 O; B" L# e+ R( ?! @# X  t
查看最大连接数
mysql> show variables like 'max_connections';
. X/ q- C4 B# L& T$ U) g  B+-----------------+-------+
+ r1 q7 l- E" o1 L# o3 x! j. l& q| Variable_name   | Value |$ O7 M1 E6 F' f
+-----------------+-------+, s& x9 H7 u% a  m4 c8 S
| max_connections | 1024  |
' E: o( J; g( s+-----------------+--------+
% W5 F# k% d, S9 N/ d7 X1 row in set (0.00 sec)
, Y6 C1 m. x& D' \' @+ n8 h  _
进行压力测试:
[root@mysql ~]# mysqlslap --defaults-file=/etc/my.cnf --concurrency=100,200 --iterations=1 --number-int-cols=20 --number-char-cols=30 \
2 Z7 E. o' j4 \% @" ^& G$ S# g! Y2 E, q, ^4 ?- m' v5 P# w
--auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --number-of-queries=2000 -uroot -p123 --verbose* t2 s) d( {, f' U
上述命令测试说明:模拟测试两次读写并发,第一次100,第二次200,自动生成SQL脚本,测试表包含20个init字段,30个char字段,每次执行2000查询请求。测试引擎分别是myisam,innodb。(上述选项中有很多都是默认值,可以省略,如果想要了解各个选项的解释,可以使用mysqlslap --help进行查询)。
测试结果说明:
  • Myisam第一次100客户端同时发起增查用0.557/s,第二次200客户端同时发起增查用0.522/s
  • Innodb第一次100客户端同时发起增查用0.256/s,第二次200客户端同时发起增查用0.303/s
    9 w# V, a6 w* v1 H6 i, h2 F: j; [
可以根据实际需求,一点点的加大并发数量进行压力测试。
微信图片_20210203123820.png
二、使用第三方sysbench工具进行压力测试
1、安装sysbench工具
[root@mysql ~]# yum -y install epel-release #安装第三方epel源1 r7 R) m, I/ s( O

$ H! l- B2 G8 L- v5 G# r[root@mysql ~]# yum -y install sysbench #安装sysbench工具
0 O2 X( U- `3 N; S, [
. f, R) F7 g8 i8 o3 R) f2 S8 W[root@mysql ~]# sysbench --version #确定工具已安装! m4 u7 ^( ~1 X% d0 ?! W
sysbench 1.0.17
4 h. W- G& G' g7 b8 S
sysbench可以进行以下测试:
  • CPU 运算性能测试
  • 磁盘 IO 性能测试
  • 调度程序性能测试
  • 内存分配及传输速度测试
  • POSIX 线程性能测试
    & ?% K% I3 P- X  }$ s" |
数据库性能测试(OLTP 基准测试,需要通过 /usr/share/sysbench/ 目录中的 Lua 脚本执行,例如 oltp_read_only.lua 脚本执行只读测试)。
sysbench 还可以通过运行命令时指定自己的 Lua 脚本来自定义测试。
2、查看sysbench工具的帮助选项
[root@mysql ~]# sysbench --help
9 K3 H, A* s8 `9 T0 P3 iUsage:
. f# L1 x. V8 L6 ]/ d3 W9 Ssysbench [options]... [testname] [command]
; F4 l- y- K( b, b; ?" }5 q
* |9 G0 w+ G7 t8 J% J" \) K$ d2 |1 R; ^Commands implemented by most tests: prepare run cleanup help # 可用的命令,四个8 d4 T, T6 t: V# {3 K/ I+ y

! r/ `( f7 f# x9 a/ U* M, SGeneral options: # 通用选项
+ P1 [: x% w0 r0 r! k1 J5 O; |--threads=N 要使用的线程数,默认 1 个 [1]
( E# A, n" J( F! l) n  g+ W0 q--events=N 最大允许的事件个数 [0]3 S: h, w" B" @2 r. F0 E% T
--time=N 最大的总执行时间,以秒为单位 [10]5 S) J# k5 T7 t! o& U/ }
--forced-shutdown=STRING 在 --time 时间限制到达后,强制关闭之前等待的秒数,默认“off”禁用(number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable) [off]
% c( c8 K$ _1 {! j--thread-stack-size=SIZE 每个线程的堆栈大小 [64K]4 _2 s- |* f& n1 @1 w
--rate=N 平均传输速率。0 则无限制 [0]' R& @$ e. P: {9 k  U; V- O
--report-interval=N 以秒为单位定期报告具有指定间隔的中间统计信息 0 禁用中间报告 [0]
0 y) q+ X  s/ Z& j4 M1 A2 Y--report-checkpoints=[LIST,...] 转储完整的统计信息并在指定的时间点重置所有计数器。参数是一个逗号分隔的值列表,表示从测试开始经过这个时间量时必须执行报告检查点(以秒为单位)。报告检查点默认关闭。 []5 L0 d1 W, @& \$ p7 i. B! r1 a
--debug[=on|off] 打印更多 debug 信息 [off]
! h5 d6 k# s% F2 ^0 P3 Z--validate[=on|off] 尽可能执行验证检查 [off]' n& o$ o  _) `9 F  K! [
--help[=on|off] 显示帮助信息并退出 [off]7 j% y8 A3 S  H5 t* ~  K% k* i% p
--version[=on|off] 显示版本信息并退出 [off]% o- j; g/ W2 f; \
--config-file=FILENAME 包含命令行选项的文件
4 `( L3 \, n; |2 {--tx-rate=N 废弃,改用 --rate [0]
( l; r( G# z9 ]--max-requests=N 废弃,改用 --events [0]
' Z, y( H, T* N8 ]- m* W8 L--max-time=N 废弃,改用 --time [0]: t0 m. r. z: e1 P1 A4 l
--num-threads=N 废弃,改用 --threads [1], i% @: [3 N7 F2 J: i6 Y) s

5 U1 K$ `: h3 F! H* sPseudo-Random Numbers Generator options: # 伪随机数发生器选项) `. B+ J6 v4 r1 B; g
--rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
3 J: C8 l: n$ m% x) M--rand-spec-iter=N number of iterations used for numbers generation [12]
( `8 e, t; m* P# D2 s+ `--rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]1 ]  x/ k9 o; O3 q2 H; B
--rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]( d1 X  k6 r- E, g# E7 d$ F
--rand-seed=N seed for random number generator. When 0, the current time is used as a RNG seed. [0]
  J5 o5 D8 m* K8 i; Z--rand-pareto-h=N parameter h for pareto distribution [0.2]* {9 G! V2 r$ E8 B1 `) t" ^
Log options: # 日志选项
1 X0 S5 K$ w# M$ l--verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]. o+ j, v) f- a5 S( _% o
--percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]/ W( q8 ?# g$ @) v& p
--histogram[=on|off] print latency histogram in report [off]
: l( t& R- ?" S2 M6 W: S
7 [9 L  T* f  L3 t' }General database options: # 通用的数据库选项
" ?! d4 K* Y0 q5 U, N7 t--db-driver=STRING 指定要使用的数据库驱动程序 ('help' to get list of available drivers)
5 U4 J' Z& z2 L. Y( ?--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
  b) G2 J+ O! O0 m7 [( ^2 m  ~- F$ k' m8 j
--db-debug[=on|off] print database-specific debug information [off]4 w2 X0 p9 ]2 J# ?1 s
Compiled-in database drivers: # 內建的数据库驱动程序,默认支持 MySQL 和 PostgreSQL8 @4 i4 r; x! M% l# y
mysql - MySQL driver( C# e$ z* _: [! y) L0 _7 @- B/ F" d
pgsql - PostgreSQL driver
9 C; b5 `4 v  U, L1 k6 W0 T6 t7 D  B7 e$ J5 q8 u- g! d
mysql options: # MySQL 数据库专用选项' b# I  i$ a& G+ Y
--mysql-host=[LIST,...] MySQL server host [localhost]1 L0 z+ l6 s! i9 u$ p
--mysql-port=[LIST,...] MySQL server port [3306]- t- B7 N! U3 }# u
--mysql-socket=[LIST,...] MySQL socket/ Y( A8 |0 N, Y6 [2 p& H
--mysql-user=STRING MySQL user [sbtest]; @1 o6 Y& _% U
--mysql-password=STRING MySQL password []
  ?* r* e  o7 T5 {! U% J( O' u, N--mysql-db=STRING MySQL database name [sbtest]
9 J+ w! X8 o1 k--mysql-ssl[=on|off] use SSL connections, if available in the client library [off]# b: M- \  ]+ K( l, N# y
--mysql-ssl-cipher=STRING use specific cipher for SSL connections []
* ]. [, B, J5 |' D, d/ B6 F--mysql-compression[=on|off] use compression, if available in the client library [off]/ i8 M  _8 X! P7 s, O
--mysql-debug[=on|off] trace all client library calls [off]' [1 u8 v7 r' v1 I2 l
--mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]
- I4 T) \3 P1 O/ \8 N% q: o8 y  L$ f--mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off], x8 d4 G) L' G. k* D
( X/ m. ~+ j8 q$ s* G  X
pgsql options: # PostgreSQL 数据库专用选项; P" h+ |( @& N7 T
--pgsql-host=STRING PostgreSQL server host [localhost]! E/ m; h# @! h8 A, y1 L/ P
--pgsql-port=N PostgreSQL server port [5432]
" _9 z. Y# Y; Z( I9 q+ v. P. A: ^--pgsql-user=STRING PostgreSQL user [sbtest]
4 V9 Q# L% a" U7 v/ Q2 Q1 A--pgsql-password=STRING PostgreSQL password []
2 l% L' R. I2 n$ H5 c--pgsql-db=STRING PostgreSQL database name [sbtest]
" X% c8 _7 ?- r- T7 Y, @: q2 G/ G4 [; S
Compiled-in tests: # 內建测试类型! ~  ~* c( J' C
fileio - File I/O test
$ |0 a  U( `% E+ [, ?* Z' y, Dcpu - CPU performance test
/ k  F+ I) A! q! D0 {! Kmemory - Memory functions speed test0 w" O  `% L/ I
threads - Threads subsystem performance test
7 \! h, U+ R0 p6 }3 Cmutex - Mutex performance test' T9 J' W3 P# v& E

$ u/ o1 Z% [: [( ~5 p: Q7 M( vSee 'sysbench <testname> help' for a list of options for each test.: Q+ @- L; l! Z, E/ h4 o) P
3、sysbench测试MySQL数据库性能
1)准备测试数据
#查看sysbench自带的lua脚本使用方法8 i9 K% a8 d7 c
[root@mysql ~]# sysbench /usr/share/sysbench/oltp_common.lua help9 k0 z, y7 n9 H& R
4 }3 C2 \- @% f  Z/ y% i# v
#必须创建sbtest库,sbtest是sysbench默认使用的库名* ~4 l" b+ t; s$ a2 W) Q+ ]
[root@mysql ~]# mysqladmin -uroot -p123 create sbtest;7 W6 x/ x# [$ H3 T% T

$ H3 V/ I1 H/ i9 ?$ u2 H#然后,准备测试所用的表,这些测试表放在测试库sbtest中。这里使用的lua脚本为/usr/share/sysbench/oltp_common.lua。& T& V& U9 m. @3 T: e
[root@mysql ~]# sysbench --mysql-host=127.0.0.1 \1 ]* \7 I- X* [+ b3 l7 ^1 Y
--mysql-port=3306 \4 h% E, m2 s% z3 w0 }
--mysql-user=root \7 q& q- Y# s) w" x
--mysql-password=123 \
; r* \: n3 z9 ~% m/usr/share/sysbench/oltp_common.lua \
+ h& h- l1 W4 N% B8 J$ u--tables=10 \( v9 z- q- B: \! j. d
--table_size=100000 \8 Y' x$ W7 z$ h7 F1 |! \/ H
prepare9 i. M6 v7 N! h# N! [" c) r9 m

  r# _% a7 j; w2 l! {8 F1 i9 Q9 M#其中--tables=10表示创建10个测试表,
2 s9 _+ H4 g# O# Z& q; B( U4 T#--table_size=100000表示每个表中插入10W行数据,
4 \& x/ G% n9 M( U7 t#prepare表示这是准备数的过程。0 z- a3 W0 U! m. ?# C
2)确认测试数据以存在
[root@mysql ~]# mysql -uroot -p123 sbtest; #登录到sbtest库, r9 u; M) T4 d! J- Q1 x$ m

. i* D0 d" s0 I# ?  u1 M, rmysql> show tables; #查看相应的表9 o/ L1 k4 m5 J, O" B" I" j% l
+------------------+
. y0 R% g# d% y: V9 p! x| Tables_in_sbtest |, p+ [- B, r3 w% y" c7 b2 I9 }
+------------------+6 J% q( T/ N1 ~! L- ]1 h3 {
| sbtest1 |
+ {, \- {- Z; i# o| sbtest10 |5 [, R$ T2 g) V: q
| sbtest2 |) c: i$ D6 z7 M5 z, t6 {
| sbtest3 |
5 s6 M& ~# R% `; ]# r. ]| sbtest4 |' s3 G% |" \5 ^8 R
| sbtest5 |
: Y8 d7 q3 |, c# y| sbtest6 |- q- w" P3 K) `( O9 q/ E; @
| sbtest7 |+ d" s* G: X6 a4 W, I
| sbtest8 |
. `3 Z! i# U& Q- m# m, j, e5 l8 ^4 G4 ^- G| sbtest9 |
* n. Y, c4 ?( v* f$ |' p2 J+------------------+
. T5 _* ?! @* v# s' e6 g: ]# M10 rows in set (0.00 sec)' Z/ L* g' N" R. f/ K
mysql> select count(*) from sbtest1; #随机选择一个表,确认其有100000条数据
% I! P, {* K' x# s- C+----------+
6 ]% {+ H' _# F2 @9 U+ V| count(*) |2 N) v' Q" O8 G
+----------+
8 [/ t3 F, @1 O( ~" z1 o5 e| 100000 |
. k9 ~- X. ?. D+----------+
4 U. A9 t& U) @0 {7 |, ^1 row in set (0.01 sec)
& n6 e3 C# f' N7 o+ l+ C6 J
3)数据库测试和结果分析
稍微修改下之前准备数据的语句,就可以拿来测试了。需要注意的是,之前使用的lua脚本为oltp_common.lua,它是一个通用脚本,是被其它lua脚本调用的,它不能直接拿来测试。
所以,我这里用oltp_read_write.lua脚本来做读、写测试。还有很多其它类型的测试,比如只读测试、只写测试、删除测试、大批量插入测试等等。可找到对应的lua脚本进行调用即可。
#执行测试命令如下:
5 o7 o# @. [9 ~0 F/ f+ d8 ~[root@mysql ~]# sysbench --threads=4 \4 b3 d. @% U' L0 |
--time=20 \/ z: s. m$ v  x) d8 X0 ^
--report-interval=5 \
! x" _5 ~  Q7 y) y--mysql-host=127.0.0.1 \
( g- a: r! T1 F  M--mysql-port=3306 \
7 e, f! ?1 Q+ i4 a( A/ u# a9 o--mysql-user=root \
; J& A- W" k* t- m# x- R! f$ X--mysql-password=123 \5 ?# b! x2 B! ^  u1 f0 Q/ T2 ?$ g+ l
/usr/share/sysbench/oltp_read_write.lua \
; ^6 F5 o- O8 T8 D, R$ ~--tables=10 \$ ~3 ^/ m; \3 I& }, R5 ]* d; ~) }
--table_size=100000 \
" w$ |& o6 c+ k  W# t( zrun1 s# ]7 F7 J# `( X5 f  Z1 E: v
上述命令返回的结果如下:
[root@mysql ~]# sysbench --threads=4 --time=20 --report-interval=5 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123 /usr/share/sysbench/oltp_read_write.lua --tables=10 --table_size=100000 run
& R0 J: G; r) W9 ]- R* I2 n% @$ C2 Z
/ F6 \# X5 m1 Z- h7 @- ~sysbench 1.0.17 (using system LuaJIT 2.0.4)0 A5 I* m. O5 ~1 _$ f: N
Running the test with following options:
9 `/ g5 H( t- b' F4 i. S$ RNumber of threads: 4  x  d3 w" c, i* E$ ]
Report intermediate results every 5 second(s)
2 a6 R2 V9 V0 G3 R* \, b; w# rInitializing random number generator from current time
6 [4 l: N) \+ o/ L$ o" ]( oInitializing worker threads...
2 _! w8 i) t% w# v$ ^8 f7 d" ^Threads started!3 p- s* y( {+ g7 S% e. Y8 P% _9 X
+ p0 S' \  o/ p# ^
#以下是每5秒返回一次的结果,统计的指标包括:
1 {/ X& s/ o* _- D6 C" s# 线程数、tps(每秒事务数)、qps(每秒查询数)、
) ^2 F9 m, j2 J  L8 b3 B1 S# 每秒的读/写/其它次数、延迟、每秒错误数、每秒重连次数
3 e; _& C1 X0 ?7 O* Q1 ][ 5s ] thds: 4 tps: 1040.21 qps: 20815.65 (r/w/o: 14573.17/4161.25/2081.22) lat (ms,95%): 7.17 err/s: 0.00 reconn/s: 0.00, g; m  A) w6 [4 i& Q2 c
[ 10s ] thds: 4 tps: 1083.34 qps: 21667.15 (r/w/o: 15165.93/4334.55/2166.68) lat (ms,95%): 6.55 err/s: 0.00 reconn/s: 0.007 E. B0 |! Z$ i& Z
[ 15s ] thds: 4 tps: 1121.57 qps: 22429.09 (r/w/o: 15700.64/4485.30/2243.15) lat (ms,95%): 6.55 err/s: 0.00 reconn/s: 0.00
% G+ X3 z. Y1 {[ 20s ] thds: 4 tps: 1141.69 qps: 22831.98 (r/w/o: 15982.65/4566.16/2283.18) lat (ms,95%): 6.09 err/s: 0.00 reconn/s: 0.00% `: ]7 J+ t! a; c

4 Y& l6 O, B$ n8 sSQL statistics:  n' D) w+ J' g) q7 s8 @

9 C" }+ l9 x" j4 U0 l2 Kqueries performed:. Y' {' t) c& k; c" V
read: 307146 # 执行的读操作数量
2 r3 ?( [, K$ B2 z) C- Pwrite: 87756 # 执行的写操作数量
, v6 m$ Y* u( s& Z9 bother: 43878 # 执行的其它操作数量4 ^" o' h; P2 _5 @: y: W2 R

- W6 L' d6 C4 r* btotal: 438780/ z0 }9 y. K7 E- \. @8 o9 G
transactions: 21939 (1096.57 per sec.) # 执行事务的平均速率" A9 j% ]6 ~  P/ q$ M5 Z
queries: 438780 (21931.37 per sec.) # 平均每秒能执行多少次查询
4 K% I$ h) G; n. t" ]1 Y% aignored errors: 0 (0.00 per sec.)) y) A6 w' o2 u
reconnects: 0 (0.00 per sec.), D7 I2 }' m$ g) M9 e5 C

+ m( Z7 y/ E5 a2 KGeneral statistics:1 i6 z, ^7 k% Y+ T8 O/ [
total time: 20.0055s # 总消耗时间% x4 J  Z( z, w% B) o% p
total number of events: 21939 # 总请求数量(读、写、其它)
7 j/ ]3 b5 O1 B' R9 x
1 f7 C2 t4 e. `2 aLatency (ms):
. ]- J6 i- `$ W3 a. _0 T/ Umin: 1.39
( j1 ^, b/ f5 davg: 3.64% a/ m( l2 K" v8 a/ p3 I
max: 192.05* C: @2 h& I. |  F8 M
95th percentile: 6.67 # 采样计算的平均延迟, J2 Z7 m* Z) B; r% z
sum: 79964.267 G" Q' x8 p. G# ?
6 }7 c$ l% J% w3 W- H
Threads fairness:
5 C1 y% D0 h2 aevents (avg/stddev): 5484.7500/15.12
$ N6 s: t- T% rexecution time (avg/stddev): 19.9911/0.008 J4 H$ W% `3 l( {% {3 D
4、cpu/io/内存等测试
sysbench内置的几个测试指标如下:
[root@mysql ~]# sysbench --help& [2 g1 L: E% F7 f
.......... # 省略部分内容. j8 t5 A0 z; I: U9 D# W/ \
Compiled-in tests:
, i7 v' j4 Q' ufileio - File I/O test
1 ]! R' o& U) S/ S% C& icpu - CPU performance test
" V& o. ^) h' W- Q; t" v. Pmemory - Memory functions speed test
6 k  W) @" g& Fthreads - Threads subsystem performance test
3 R+ r5 R4 d. Emutex - Mutex performance test
( h' J) g1 e% i- i1 \
可以直接help输出测试方法,例如,fileio测试:
[root@mysql ~]# sysbench fileio help
. ^) G0 v4 n# l$ J! z( {sysbench 1.0.17 (using system LuaJIT 2.0.4)0 k) H4 }! a/ D  W5 X8 |/ m8 ~

( B7 h: n* H1 \! `8 y! v* vfileio options:) Q$ T: B2 B) M) J+ l9 O, s/ m7 ?
--file-num=N number of files to create [128]$ T) P* O# y3 v3 [
--file-block-size=N block size to use in all IO operations [16384]9 c& z. h& d4 O# {+ j# c* S6 `
--file-total-size=SIZE total size of files to create [2G]
3 i4 f' d/ C" P! g- i$ X% `--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}6 Y. G& p" c" E  B: b
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync]% o7 I- D) ~  y9 i- N
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]' i. w6 H4 R# t" m5 t6 z
--file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []- e9 K& }$ S& I  q. }5 S
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
; y, y6 D" Y7 _--file-fsync-all[=on|off] do fsync() after each write operation [off]/ k% H" h# L5 j0 d
--file-fsync-end[=on|off] do fsync() at the end of test [on]! d( t( ~5 Q3 ?; m. B* ~4 d. C
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
. w6 S2 g/ g! g) w0 f0 B--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
8 X( L0 [# k. i: g% C. _  j+ _--file-rw-ratio=N reads/writes ratio for combined test [1.5]
/ Z' r3 {9 b9 r' t& [* G
1)测试io性能
例如,创建5个文件,总共2G,每个文件大概400M。
[root@mysql ~]# sysbench fileio --file-num=5 --file-total-size=2G prepare1 y' h& C7 d# G2 |9 N5 a
[root@mysql ~]# ll -lh test*$ }! X7 g; I- ]4 N& Y& A8 k
-rw------- 1 root root 410M May 26 16:05 test_file.0
- b9 O. @2 E- y-rw------- 1 root root 410M May 26 16:05 test_file.1
4 z; p1 a, f+ A" i-rw------- 1 root root 410M May 26 16:05 test_file.2
0 m* h$ p3 p; U-rw------- 1 root root 410M May 26 16:05 test_file.36 d1 W# b3 }9 {  D4 l+ X
-rw------- 1 root root 410M May 26 16:05 test_file.4
! c  {: V$ v% n- G( K  H
然后运行测试:
[root@mysql ~]# sysbench --events=5000 \
2 k+ q0 h! V) t9 d6 g: ~--threads=16 \
) g3 g* T9 m3 Z5 I) d) X) M8 v$ Rfileio \/ d2 N/ N7 r  S
--file-num=5 \
" y6 D' Q% {1 V& {" _; ?9 d. _3 F2 Q--file-total-size=2G \& |6 J' U& E! j$ T2 D# m( J
--file-test-mode=rndrw \+ U' l; G) ^8 ]& H; g* h
--file-fsync-freq=0 \
5 I5 W7 t0 ~' C- B5 C--file-block-size=16384 \
8 V: a9 p- ]! j! B/ X  Zrun
/ r2 ^* W7 M9 |. p' A, u4 l9 @
返回的结果如下:
Running the test with following options:) i& l, J# `) V7 q5 u" Y2 m$ ]) A
Number of threads: 16# _0 Y6 U7 s+ M( U
Initializing random number generator from current time
7 `9 ]5 d+ m& t" Q' U/ T, rExtra file open flags: (none)' Z5 `9 q2 s) ?$ @& V
5 files, 409.6MiB each( F1 J  Z) S5 h7 o
2GiB total file size. o9 {* N& q( `
Block size 16KiB
! D/ N" C! L: VNumber of IO requests: 5000
8 z) r, B( e8 K2 {# rRead/Write ratio for combined random IO test: 1.50
- A" D: g& t; ~3 i7 u" w( b/ \Calling fsync() at the end of test, Enabled.6 h' r& [& K  F7 y) u/ e; N1 z
Using synchronous I/O mode
& v) \, R( d$ t+ kDoing random r/w test
+ E4 ?. o! r6 l8 |; R9 KInitializing worker threads...
7 m0 X  G, {9 I: V- b  g- A; Y% \4 R- x( J
Threads started!1 D& y. W8 ]! v9 N; i7 d" y8 k( E

+ X0 k, p  d. l8 K' hFile operations:9 Y/ ~4 A+ Q$ ^, N
reads/s: 9899.03
* H4 }6 Q! U+ G! W$ K! `writes/s: 6621.38
% {! W  Q5 u) W* f% M3 Jfsyncs/s: 264.33
; f7 ~; z% J7 j% d0 _5 [Throughput: # 吞吐量5 Q  c6 {+ P6 Q3 o( X
read, MiB/s: 154.66 #表示读带宽
  t: `, ?7 A6 ?written, MiB/s: 103.46 #表示写的带宽
, l9 p* ~. H7 |+ ?2 d  m- ?- `) V, ?) X* I4 a  T
General statistics:
2 g2 n: S. H6 S# N* Ytotal time: 0.3014s6 k. E" ~$ x' x
total number of events: 5000
3 S1 I8 B( ~  x  [7 F! v& t  E% S+ L% Q1 z! {$ s1 B* [# _- \
Latency (ms):
7 e; Q- _) X* Z$ O  [- @min: 0.00# `) L7 \, ^% i% U' f
avg: 0.814 {& S  j) ?. c" p& q
max: 53.56( y5 W% G; G/ O# f/ [0 T: |4 i
95th percentile: 4.10
. Y/ a. w$ N3 K* vsum: 4030.48
; Y: ]& G! s7 d% b$ I  g) E* ]
0 d- ^# S; V) ]% C5 oThreads fairness:
* t, Z7 _& X6 \  a8 W+ u8 G. K: [' oevents (avg/stddev): 312.5000/27.64: h+ |& ~( N9 t/ i* o) {0 Q
execution time (avg/stddev): 0.2519/0.02
% E, k- P+ a0 Z8 N" `1 J! j7 [
2)测试cpu性能
[root@mysql ~]# sysbench cpu --threads=40 --events=10000 --cpu-max-prime=20000 run: Z% C5 Q5 l6 g9 F
压测时,还请小心谨慎!!!!

3 K8 L* k( n3 Z$ _; f* S  q
赞 收藏 评论0 发布时间:2021-2-3 12:40

举报

0个回答
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版