加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

使用 MySQL Slap 的参考和指南

发布时间:2023-10-21 13:59:16 所属栏目:MySql教程 来源:
导读:小编给大家分享一下MySQL基准压力测试工具MySQLSlap怎么用,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!常用的解释:[root@zhan

小编给大家分享一下MySQL基准压力测试工具MySQLSlap怎么用,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

常用的解释:

[root@zhanglin ~]# mysqlslap --help

mysqlslap Ver 1.0 Distrib 5.1.73, for redhat-linux-gnu (x86_64)

Copyright (c) 2005, 2013, 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/mysql/my.cnf /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.

--defaults-file=#   Only read default options from the given file #.

--defaults-extra-file=# Read this file after the global files are read.

 -?, --help     Display this help and exit.

 -a, --auto-generate-sql 

           Generate SQL where not supplied by file or command line.  //系统自带生成的SQL脚本来测试,非文件或命令行。

 --auto-generate-sql-add-autoincrement 

           Add an AUTO_INCREMENT column to auto-generated tables.   //从5.1.18版本开始,?表示对生成的表自动添加auto_increment列。

 --auto-generate-sql-execute-number=# 

           Set this number to generate a set number of queries to   //设置会话执行SQL语句的次数

           run.

 --auto-generate-sql-guid-primary 

           Add GUID based primary keys to auto-generated tables.    //给测试表,根据主键添加GUID字段

 --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          // 自动测试生成的不同write SQL 语句的个数。

           auto-generate-sql-write-number.

 --auto-generate-sql-write-number=# 

           Number of row inserts to perform for each thread (default  //每个线程write SQL的数量。

           is 100).

 --commit=#     Commit records every X number of statements.        //多少条DML后提交一次。

 -C, --compress   Use compression in server/client protocol.         // 使用压缩。

 -c, --concurrency=name 

           Number of clients to simulate for query to run.     //客户端并发数量,多个可以用逗号隔开,例如:concurrency=100,500,1000, 并发连接线程数分别是100、500、1000个并发。

 --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  //以CSV 文件输出测试结果。

           is named.

 -#, --debug[=#]  This is a non-debug version. Catch this and exit.

 --debug-check   Check memory and open file usage at exit.         //检查CPU以及内存的相关信息。

 -T, --debug-info  Print some debug info at exit.               //结束时 打印debug信息。

 -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.

 -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.             //-i N 测试执行的次数,代表要在不同并发环境下,各自运行测试多少次。

 --no-drop     Do not drop the schema after the test.           //测试结束,保留测试用户数据。

 -x, --number-char-cols=name                          //创建测试表的 varchar 型字段数量,默认是1。

           Number of VARCHAR columns to create in table if

           specifying --auto-generate-sql.

 -y, --number-int-cols=name                           //创建测试表的 int 型字段数量,默认是1.

           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  //每个客户端 总的执行SQL次数(并发客户数×每客户查询次数)。

           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  //链接MySQL数据库用户的登录密码。

           not given it's asked from the tty. 

 -P, --port=#    Port number to use for connection.              //端口号。

 --post-query=name Query to run or file containing query to execute after    //测试后 执行的SQL语句

           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   //测试前 执行的SQL语句

           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.        //测试的SQL语句 一般是自主设计的SQL

 -s, --silent    Run program in silent mode - no output.           //不显示测试

 -S, --socket=name The socket file to use for connection.            //连接服务器的socket通道文件

 --ssl       Enable SSL for connection (automatically enabled with

           other flags).Disable with --skip-ssl.

 --ssl-ca=name   CA file in PEM format (check OpenSSL docs, implies

           --ssl).

 --ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).

 --ssl-cert=name  X509 cert in PEM format (implies --ssl).

 --ssl-cipher=name SSL cipher to use (implies --ssl).

 --ssl-key=name   X509 key in PEM format (implies --ssl).

 --ssl-verify-server-cert 

           Verify server's "Common Name" in its cert against

           hostname used when connecting. This option is disabled by

           default.

 -u, --user=name  User for login if not current user.             // 登录MySQL用户,

 -v, --verbose   More verbose output; you can use this multiple times to   //更详细的输出。

           get even more verbose output.

 -V, --version   Output version information and exit.             //版本信息

测试命令:

mysqlslap -uroot -pzhanglin --concurrency=1000 --iterations=10 --auto-generate-sql --auto-generate-sql-load-type=mixed --auto-generate-sql-add-autoincrement --engine=myisam --number-of-queries=10 --debug-info

 #备注本次测试以1000个并发线程、测试10次,自动生成SQL测试脚本、读、写、更新混合测试、自增长字段、测试引擎为myisam、共运行10次查询,输出cpu资源信息。

mysqlslap --concurrency=10,200,1000 --iterations=20 --number-int-cols=8 --number-char-cols=30 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=read --engine=myisam,innodb --number-of-queries=5000 --verbose --socket=/tmp/mysql/mysql.sock -uroot -pzhanglin

  #系统脚本测试,增加int型 8列char 型30列,测试2种引擎myisam,innodb读的性能,分别用10,200,1000个客户端对服务器进行测试总共5000个查询语句 执行20次查询。

以上是“MySQL基准压力测试工具MySQLSlap怎么用”这篇文章的所有内容,感谢各位的阅读!

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章