0 1 2 3 4 5 6 7 8 9 10 |
[root@DB1 ~]# uname -a Linux DB1.t4x.org 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@DB1 ~]# cat /etc/redhat-release CentOS release 6.8 (Final) [root@DB1 ~]# cat /proc/cpuinfo | grep processor processor : 0 [root@DB1 ~]# free -m total used free shared buffers cached Mem: 980 900 80 0 98 174 -/+ buffers/cache: 627 353 Swap: 1983 0 1983 |
0 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 |
[root@DB1 ~]# mysqlslap --concurrency=1,50,100,200 --iterations=3 --number-int-cols=5 --number-char-cols=5 --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=myisam,innodb --number-of-queries=10 --create-schema=sbtest -uroot -p123456 mysqlslap: [Warning] Using a password on the command line interface can be insecure. Benchmark Running for engine myisam Average number of seconds to run all queries: 0.024 seconds Minimum number of seconds to run all queries: 0.008 seconds Maximum number of seconds to run all queries: 0.056 seconds Number of clients running queries: 1 Average number of queries per client: 10 Benchmark Running for engine myisam Average number of seconds to run all queries: 2.000 seconds Minimum number of seconds to run all queries: 1.029 seconds Maximum number of seconds to run all queries: 3.028 seconds Number of clients running queries: 50 Average number of queries per client: 0 Benchmark Running for engine myisam Average number of seconds to run all queries: 2.733 seconds Minimum number of seconds to run all queries: 2.293 seconds Maximum number of seconds to run all queries: 3.046 seconds Number of clients running queries: 100 Average number of queries per client: 0 Benchmark Running for engine myisam Average number of seconds to run all queries: 5.812 seconds Minimum number of seconds to run all queries: 5.212 seconds Maximum number of seconds to run all queries: 6.289 seconds Number of clients running queries: 200 Average number of queries per client: 0 Benchmark Running for engine innodb Average number of seconds to run all queries: 0.067 seconds Minimum number of seconds to run all queries: 0.027 seconds Maximum number of seconds to run all queries: 0.141 seconds Number of clients running queries: 1 Average number of queries per client: 10 Benchmark Running for engine innodb Average number of seconds to run all queries: 0.395 seconds Minimum number of seconds to run all queries: 0.324 seconds Maximum number of seconds to run all queries: 0.500 seconds Number of clients running queries: 50 Average number of queries per client: 0 Benchmark Running for engine innodb Average number of seconds to run all queries: 1.308 seconds Minimum number of seconds to run all queries: 1.137 seconds Maximum number of seconds to run all queries: 1.487 seconds Number of clients running queries: 100 Average number of queries per client: 0 Benchmark Running for engine innodb Average number of seconds to run all queries: 1.733 seconds Minimum number of seconds to run all queries: 1.330 seconds Maximum number of seconds to run all queries: 2.440 seconds Number of clients running queries: 200 Average number of queries per client: 0 [root@DB1 ~]# mysqlslap --concurrency=1,50,100,200 --iterations=3 --number-int-cols=5 --number-char-cols=5 --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=myisam,innodb --number-of-queries=10 --create-schema=sbtest -uroot -p123456 --only-print | more |
参数说明:
--concurrency代表并发数量,多个可以用逗号隔开,concurrency=10,50,100, 并发连接线程数分别是10、50、100个并;
--engines代表要测试的引擎,可以有多个,用分隔符隔开
--iterations代表要运行这些测试多少次;
--auto-generate-sql 代表用系统自己生成的SQL脚本来测试;
--auto-generate-sql-load-type 代表要测试的是读还是写还是两者混合的(read,write,update,mixed);
--number-of-queries 代表总共要运行多少次查询。每个客户运行的查询数量可以用查询总数/并发数来计算;
--debug-info 代表要额外输出CPU以及内存的相关信息;
--number-int-cols :创建测试表的 int 型字段数量;
--auto-generate-sql-add-autoincrement : 代表对生成的表自动添加auto_increment列,从5.1.18版本开始;
--number-char-cols 创建测试表的 char 型字段数量;
--create-schema 测试的schema,MySQL中schema也就是database;
--query 使用自定义脚本执行测试,例如可以调用自定义的一个存储过程或者sql语句来执行测试;
--only-print 如果只想打印看看SQL语句是什么,可以用这个选项;SourceByrd's Weblog-https://note.t4x.org/database/mysqlslap-benchmark-test/指定数据库和sql语句:
mysqlslap -h192.168.3.18 -P4040 --concurrency=100 --iterations=1 --create-schema='test' --query='select * from test;' --number-of-queries=10 --debug-info -uroot -poracle SourceByrd's Weblog-https://note.t4x.org/database/mysqlslap-benchmark-test/
错误解决:SourceByrd's Weblog-https://note.t4x.org/database/mysqlslap-benchmark-test/
SourceByrd's Weblog-https://note.t4x.org/database/mysqlslap-benchmark-test/
0123 Q:server: 2001 Can't create UNIX socket (24)A:ulimit -HSn 65535Q:Error when connecting to server: 1040 Too many connectionsA:max_connections = 4000 OR set global max_connections=4000;
参考文档:
1:https://www.2cto.com/database/201301/186827.htmlSourceByrd's Weblog-https://note.t4x.org/database/mysqlslap-benchmark-test/
SourceByrd's Weblog-https://note.t4x.org/database/mysqlslap-benchmark-test/