PS: 还在翻译中,虽然翻译得很水,很不专业,慢慢有了一定的术语积累后,我会慢慢努力调整滴!
mysqlslap — Load Emulation Client
系统中可以这样调用mysqlslap:
shell> mysqlslap [选项]
例如,有选项 --create 或 --query 能让你指定一个包含一条SQL语句的字符串或者一个描述文件。如果你指定了一个文件,默认该文件必须包含每行一个语句。
(另,默认的语句限定符就是换行符。)使用 --delimiter 选项可以指定一个不同的界定符,这样就能让你指定跨多行的语句或在一行上写多行语句.需要注意的
是,mysqlslap不理解注释,所以文件中不能有!
mysqlslap运行分三个阶段:
创建schema,table和任何用来测试的已经存储了的程序和数据. 这个阶段使用单客户端连接.
进行负载测试. 这个阶段使用多客户端连接.
清除(断开连接,删除指定表). 这个阶段使用单客户端连接.
例子:
a.提供你自己的创建和查询SQL语句,有50个客户端查询每个查询200次 (在单行上输入命令):
mysqlslap --delimiter=";"
--create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)"
--query="SELECT * FROM a" --concurrency=50 --iterations=200
b.让mysqlslap创建查询的SQL语句,使用的表有2个INT行和3个VARCHAR行.使用5个客户端,每一个查询20次!不要创建表或插入数据.(换言之,用之前测试的模式和数据):
mysqlslap --concurrency=5 --iterations=20
--number-int-cols=2 --number-char-cols=3
--auto-generate-sql
c. 告诉程序从指定的create.sql文件去加载create,insert和查询等SQL语句, 该文件有多个表的create和insert语句, 它们都是通过';'分隔开的. query.sql文件则有
多个查询语句, 分隔符也是';', 执行所有的加载语句,然后通过查询文件执行所有的查询语句,分别在5个客户端上每个执行5次:
mysqlslap --concurrency=5
--iterations=5 --query=query.sql --create=create.sql
--delimiter=";"
mysqlslap支持如下的选项, 这些选项能被指定在命令行或者在打开的文件的[mysqlslap]和[client]组中. mysqlslap同样支持选项中指定处理相应的文件!这部分的详细描述可以看“Command-Line Options that Affect Option-File Handling”.
!======================================================================================
Table 4.8. mysqlslap Options [这个表暂时未译]
Format Option File Description Introduced
--auto-generate-sql auto-generate-sql Generate SQL statements automatically when they are not supplied in files or using command options
--auto-generate-sql-add-autoincrement auto-generate-sql-add-autoincrement Add AUTO_INCREMENT column to automatically generated tables
--auto-generate-sql-execute-number=# auto-generate-sql-execute-number Specify how many queries to generate automatically
--auto-generate-sql-guid-primary auto-generate-sql-guid-primary Add a GUID-based primary key to automatically generated tables
--auto-generate-sql-load-type=type auto-generate-sql-load-type Specify how many queries to generate automatically
--auto-generate-sql-secondary-indexes=# auto-generate-sql-secondary-indexes Specify how many secondary indexes to add to automatically generated tables
--auto-generate-sql-unique-query-number=# auto-generate-sql-unique-query-number How many different queries to generate for automatic tests.
--auto-generate-sql-unique-write-number=# auto-generate-sql-unique-write-number How many different queries to generate for --auto-generate-sql-write-number
--auto-generate-sql-write-number=# auto-generate-sql-write-number How many row inserts to perform on each thread
--commit=# commit How many statements to execute before committing.
--compress compress Compress all information sent between the client and the server
--concurrency=# concurrency The number of clients to simulate when issuing the SELECT statement
--create=value create The file or string containing the statement to use for creating the table
--create-and-drop-schema=value create-and-drop-schema The schema in which to run the tests; dropped at the end of the test run 5.6.3
--create-schema=value create-schema The schema in which to run the tests
--csv=[file] csv Generate output in comma-separated values format
--debug[=debug_options] debug Write a debugging log
--debug-check debug-check Print debugging information when the program exits
--debug-info debug-info Print debugging information, memory and CPU statistics when the program exits
--default-auth=plugin default-auth=plugin The authentication plugin to use 5.6.2
--delimiter=str delimiter The delimiter to use in SQL statements
--detach=# detach Detach (close and reopen) each connection after each N statements
--enable-cleartext-plugin enable-cleartext-plugin Enable cleartext authentication plugin 5.6.7
--engine=engine_name engine The storage engine to use for creating the table
--help Display help message and exit
--host=host_name host Connect to the MySQL server on the given host
--iterations=# iterations The number of times to run the tests
--login-path=name Read login path options from .mylogin.cnf 5.6.6
--number-char-cols=# number-char-cols The number of VARCHAR columns to use if --auto-generate-sql is specified
--number-int-cols=# number-int-cols The number of INT columns to use if --auto-generate-sql is specified
--number-of-queries=# number-of-queries Limit each client to approximately this number of queries
--only-print only-print Do not connect to databases. mysqlslap only prints what it would have done
--password[=password] password The password to use when connecting to the server
--pipe On Windows, connect to server using a named pipe
--plugin-dir=path plugin-dir=path The directory where plugins are located 5.6.2
--port=port_num port The TCP/IP port number to use for the connection
--post-query=value post-query The file or string containing the statement to execute after the tests have completed
--post-system=str post-system The string to execute using system() after the tests have completed
--pre-query=value pre-query The file or string containing the statement to execute before running the tests
--pre-system=str pre-system The string to execute using system() before running the tests
--protocol=type protocol The connection protocol to use
--query=value query The file or string containing the SELECT statement to use for retrieving data
--silent silent Silent mode
--socket=path socket For connections to localhost
--ssl-ca=file_name ssl-ca The path to a file that contains a list of trusted SSL CAs
--ssl-capath=dir_name ssl-capath The path to a directory that contains trusted SSL CA certificates in PEM format
--ssl-cert=file_name ssl-cert The name of the SSL certificate file to use for establishing a secure connection
--ssl-cipher=cipher_list ssl-cipher A list of allowable ciphers to use for SSL encryption
--ssl-crl=file_name ssl-crl The path to a file that contains certificate revocation lists 5.6.3
--ssl-crlpath=dir_name ssl-crlpath The path to a directory that contains certificate revocation list files 5.6.3
--ssl-key=file_name ssl-key The name of the SSL key file to use for establishing a secure connection
--ssl-verify-server-cert ssl-verify-server-cert The server's Common Name value in its certificate is verified against the host name used when connecting to the server
--user=user_name, user MySQL user name to use when connecting to server
--verbose Verbose mode
--version Display version information and exit
!======================================================================================
--help, -?
显示帮助信息和退出.
--auto-generate-sql, -a
自动生成sql语句,当没有使用命令选项或在文件中提供的时候,可以用该选项.
--auto-generate-sql-add-autoincrement
添加一个 AUTO_INCREMENT 列去自动生成表.
--auto-generate-sql-execute-number=N
指定自动生成的查询数
--auto-generate-sql-guid-primary
添加一个基于GUID的主键来自动生成表.
--auto-generate-sql-load-type=type
指定负载测试的类型. 允许设置得类型有 read(扫描表), write(插入数据到表中), key(读取主键值), update(更新主键值), 或 mixed(一半插入,一半扫描选择).
默认是 mixed 类型.
--auto-generate-sql-secondary-indexes=N
指定有多少二级索引添加到自动生成的表中. 默认是不添加.
--auto-generate-sql-unique-query-number=N
为自动检测指定生成的查询次数. 例如,如果你运行一个执行1000次选择的键值测试,你能使用这个选项,赋值为1000来执行1000次唯一的查询,或者赋值为50来
执行50次不同的选择. 默认值是10.
--auto-generate-sql-unique-write-number=N
为 "--auto-generate-sql-write-number" 生成多少次查询. 默认是10.
--auto-generate-sql-write-number=N
单进程执行多少次行的插入. 默认是100.
--commit=N
提交前执行多少次语句. 默认是0 (也就是不提交).
--compress, -C
压缩所有在服务器和客户端之间传输的信息,当然,要服务器和客户端都支持压缩.
--concurrency=N, -c N
模拟多少并发的客户端查询.
The number of clients to simulate when issuing the SELECT statement.
--create=value
指定用来创建表的文件或者字符串.
--create-and-drop-schema=value
选择运行在测试中的模式. 运行结束后, mysqlslap删除该模式. 这个选项在5.6.3中被添加!
The schema in which to run the tests. mysqlslap drops the schema at the end of the test run. This option was added in MySQL 5.6.3.
--create-schema=value
选择运行在测试中的模式.
The schema in which to run the tests.
注意:
如果 "--auto-generate-sql" 也被给出, mysqlslap也会在运行结束后删除该模式. 为了避免这个,建议直接用 "--create-and-drop-schema" 代替它.
--csv[=file_name]
生成输出,值用逗号分开的格式. 输出到指定的文件,如果没给出指定文件,则标准输出.
--debug[=debug_options], -# [debug_options]
写入调试日志. 一个典型的调试选项的字符串是 'd:t:o, file_name'. 默认的是 'd:t:o,/tmp/mysqlslap.trace'.
--debug-check
调试检查. 当程序退出时打印一些调试信息.
--debug-info, -T
当程序退出时, 打印调试信息以及内存和CPU的使用量统计.
--default-auth=plugin
使用客户端认证插件. See Section 6.3.7, “Pluggable Authentication”.
这个选项在 MySQL 5.6.2 中添加进去的.
--delimiter=str, -F str
分界符, 在文件或命令选项中的SQU语句有效.
--detach=N
在每N条语句之后,断开每个连接(关闭和重新打开). 默认是0(即连接不断开.)
--enable-cleartext-plugin
启动 mysql_clear_password明文认证插件. (See Section 6.3.7.5, “The Cleartext Client-Side Authentication Plugin”.)这个选项在 MySQL 5.6.7上添加.
--engine=engine_name, -e engine_name
指定创表所使用的存储引擎.
--host=host_name, -h host_name
在指定的主机上连接到MySQL服务器.
--iterations=N, -i N
测试执行地次数.
--number-char-cols=N, -x N
VARCHAR列的数量,如果 "--auto-generate-sql" 指定了的话.
--number-int-cols=N, -y N
INT列的数量,如果 " --auto-generate-sql" 被指定了的话.
--number-of-queries=N
限制每个客户端大概这么多的查询次数. 查询统计考虑了语句的分隔符. 例如,如果你像下面这样调用了mysqlslap, ";" 分隔符会被认出,那么如下的
每个查询实例将被统计为两次查询. 结果是,5列 (不是10)被插入.
shell>shell> mysqlslap --delimiter=";" --number-of-queries=10
--query="use test;insert into t values(null)"
--only-print
不连接到数据库. mysqlslap仅仅打印它会做什么.
--password[=password], -p[password]
连接服务器的密码. 如果使用简短的选项格式 "-p", 你不能在选项和密码之间加上空格. 如果在命令行输入的时候,你在 "--password" 和 "-p"选项的后面
省略密码值, mysqlslap 会提示你输入密码.
在命令行直接指定密码是不安全的. See Section 6.1.2.1, “End-User Guidelines for Password Security”. 你可以使用一个选项文件去避免直接在
命令行给出密码.
--pipe, -W
在Windows上,连接服务器只用一个命名的管道. 这个选项仅仅能应用到支持命令管道连接的服务器上.
--plugin-dir=path
The directory in which to look for plugins. It may be necessary to specify this option if the --default-auth option is used to specify an authentication plugin but mysqlslap does not find it. See Section 6.3.7, “Pluggable Authentication”.
This option was added in MySQL 5.6.2.
--port=port_num, -P port_num
The TCP/IP port number to use for the connection.
--post-query=value
The file or string containing the statement to execute after the tests have completed. This execution is not counted for timing purposes.
--shared-memory-base-name=name
On Windows, the shared-memory name to use, for connections made using shared memory to a local server. This option applies only if the server supports shared-memory connections.
--post-system=str
The string to execute using system() after the tests have completed. This execution is not counted for timing purposes.
--pre-query=value
The file or string containing the statement to execute before running the tests. This execution is not counted for timing purposes.
--pre-system=str
The string to execute using system() before running the tests. This execution is not counted for timing purposes.
--protocol={TCP|SOCKET|PIPE|MEMORY}
The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the permissible values, see Section 4.2.2, “Connecting to the MySQL Server”.
--query=value, -q value
The file or string containing the SELECT statement to use for retrieving data.
--silent, -s
Silent mode. No output.
--socket=path, -S path
For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
--ssl*
Options that begin with --ssl specify whether to connect to the server using SSL and indicate where to find SSL keys and certificates. See Section 6.3.9.4, “SSL Command Options”.
--user=user_name, -u user_name
The MySQL user name to use when connecting to the server.
--verbose, -v
Verbose mode. Print more information about what the program does. This option can be used multiple times to increase the amount of information.
--version, -V
Display version information and exit.