Gitlib Gitlib
首页
  • 分类
  • 标签
  • 归档
  • Golang开发实践万字总结
  • MySQL核心知识汇总
  • Redis实践总结
  • MQ实践万字总结
  • Docker数据持久化总结
  • Docker网络模式深度解读
  • 常用游戏反外挂技术总结
  • 读书笔记
  • 心情杂货
  • 行业杂谈
  • 友情链接
关于我
GitHub (opens new window)

Ravior

以梦为马,莫负韶华
首页
  • 分类
  • 标签
  • 归档
  • Golang开发实践万字总结
  • MySQL核心知识汇总
  • Redis实践总结
  • MQ实践万字总结
  • Docker数据持久化总结
  • Docker网络模式深度解读
  • 常用游戏反外挂技术总结
  • 读书笔记
  • 心情杂货
  • 行业杂谈
  • 友情链接
关于我
GitHub (opens new window)
  • 操作系统

  • 计算机网络

  • 数据结构和算法

  • MySQL

    • MySQL数据库安装及使用入门
    • SQL语句分类
    • Mysql基础操作
    • Mysql性能测试工具mysqlslap
    • Mysql存储引擎比较
    • Mysql查询慢日志
    • Mysql binlog详解
    • Mysql主从复制
    • Mysql核心知识汇总
    • Mysql中间件MyCat使用
    • Mysql中分表和分区差异
    • MySql表锁、行锁、共享锁、排他锁、乐观锁、悲观锁
    • 深入理解Mysql复制机制
    • 深入理解Mysql事务
    • 深入理解Mysql索引
    • 谈一谈Mysql分库分表
    • Mysql常见优化技巧
  • Redis

  • Nginx

  • MongoDB

  • 其他

  • 计算机基础
  • MySQL
Ravior
2016-03-08

Mysql性能测试工具mysqlslap

mysqlslap是MySQL5.1.4之后自带的benchmark基准测试工具,该工具可以模拟多个客户端同时并发的向服务器发出查询更新,给出了性能测试数据而且提供了多种引擎的性能比较。

  1. 查看帮助信息
gitlib@devops:~$ mysqlslap --help
mysqlslap  Ver 1.0 Distrib 5.7.26, for Linux (x86_64)
Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Run a query multiple times against the server.

Usage: mysqlslap [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 
The following groups are read: mysqlslap client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
                        except for login file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
                        Also read groups with concat(group, suffix)
--login-path=#          Read this path from the login file.
  -?, --help          Display this help and exit.
  -a, --auto-generate-sql 
                      Generate SQL where not supplied by file or command line.
  --auto-generate-sql-add-autoincrement 
                      Add an AUTO_INCREMENT column to auto-generated tables.
  --auto-generate-sql-execute-number=# 
                      Set this number to generate a set number of queries to
                      run.
  --auto-generate-sql-guid-primary 
                      Add GUID based primary keys to auto-generated tables.
  --auto-generate-sql-load-type=name 
                      Specify test load type: mixed, update, write, key, or
                      read; default is mixed.
  --auto-generate-sql-secondary-indexes=# 
                      Number of secondary indexes to add to auto-generated
                      tables.
  --auto-generate-sql-unique-query-number=# 
                      Number of unique queries to generate for automatic tests.
  --auto-generate-sql-unique-write-number=# 
                      Number of unique queries to generate for
                      auto-generate-sql-write-number.
  --auto-generate-sql-write-number=# 
                      Number of row inserts to perform for each thread (default
                      is 100).
  --commit=#          Commit records every X number of statements.
  -C, --compress      Use compression in server/client protocol.
  -c, --concurrency=name 
                      Number of clients to simulate for query to run.
  --create=name       File or string to use create tables.
  --create-schema=name 
                      Schema to run tests in.
  --csv[=name]        Generate CSV output to named file or to stdout if no file
                      is named.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
  --debug-check       This is a non-debug version. Catch this and exit.
  -T, --debug-info    This is a non-debug version. Catch this and exit.
  --default-auth=name Default authentication client-side plugin to use.
  -F, --delimiter=name 
                      Delimiter to use in SQL statements supplied in file or
                      command line.
  --detach=#          Detach (close and reopen) connections after X number of
                      requests.
  --enable-cleartext-plugin 
                      Enable/disable the clear text authentication plugin.
  -e, --engine=name   Storage engine to use for creating the table.
  -h, --host=name     Connect to host.
  -i, --iterations=#  Number of times to run the tests.
  --no-drop           Do not drop the schema after the test.
  -x, --number-char-cols=name 
                      Number of VARCHAR columns to create in table if
                      specifying --auto-generate-sql.
  -y, --number-int-cols=name 
                      Number of INT columns to create in table if specifying
                      --auto-generate-sql.
  --number-of-queries=# 
                      Limit each client to this number of queries (this is not
                      exact).
  --only-print        Do not connect to the databases, but instead print out
                      what would have been done.
  -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  --plugin-dir=name   Directory for client-side plugins.
  -P, --port=#        Port number to use for connection.
  --post-query=name   Query to run or file containing query to execute after
                      tests have completed.
  --post-system=name  system() string to execute after tests have completed.
  --pre-query=name    Query to run or file containing query to execute before
                      running tests.
  --pre-system=name   system() string to execute before running tests.
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -q, --query=name    Query to run or file containing query to run.
  --secure-auth       Refuse client connecting to server if it uses old
                      (pre-4.1.1) protocol. Deprecated. Always TRUE
  -s, --silent        Run program in silent mode - no output.
  -S, --socket=name   The socket file to use for connection.
  --sql-mode=name     Specify sql-mode to run mysqlslap tool.
  --ssl-mode=name     SSL connection mode.
  --ssl               Deprecated. Use --ssl-mode instead.
                      (Defaults to on; use --skip-ssl to disable.)
  --ssl-verify-server-cert 
                      Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.
  --ssl-ca=name       CA file in PEM format.
  --ssl-capath=name   CA directory.
  --ssl-cert=name     X509 cert in PEM format.
  --ssl-cipher=name   SSL cipher to use.
  --ssl-key=name      X509 key in PEM format.
  --ssl-crl=name      Certificate revocation list.
  --ssl-crlpath=name  Certificate revocation list path.
  --tls-version=name  TLS version to use, permitted values are: TLSv1, TLSv1.1
  -u, --user=name     User for login if not current user.
  -v, --verbose       More verbose output; you can use this multiple times to
                      get even more verbose output.
  -V, --version       Output version information and exit.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  1. 以自动生成测试表和数据的形式,分别模拟 50 和 100 个客户端并发连接处理 1000 个 query 的情况。
gitlib@devops:~$ mysqlslap --create-schema='test' -q "SELECT * FROM user" -c 50,100 -i 1000 -h 127.0.0.1 -u root -p123456
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
	Average number of seconds to run all queries: 0.027 seconds
	Minimum number of seconds to run all queries: 0.020 seconds
	Maximum number of seconds to run all queries: 0.077 seconds
	Number of clients running queries: 50
	Average number of queries per client: 1

Benchmark
	Average number of seconds to run all queries: 0.067 seconds
	Minimum number of seconds to run all queries: 0.034 seconds
	Maximum number of seconds to run all queries: 1.016 seconds
	Number of clients running queries: 100
	Average number of queries per client: 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#MySQL
上次更新: 2022/12/01, 11:09:34
Mysql基础操作
Mysql存储引擎比较

← Mysql基础操作 Mysql存储引擎比较→

最近更新
01
常用游戏反外挂技术总结
11-27
02
Golang开发实践万字总结
11-11
03
Redis万字总结
10-30
更多文章>
Theme by Vdoing | Copyright © 2011-2022 Ravior | 粤ICP备17060229号-3 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式