• mysql 性能测试 mysqlslap 的使用介绍


    一、帮助文档

      -?, --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.
                         (将自动增量列添加到自动生成的表中)
                        
      --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.
                          (将基于guid的主键添加到自动生成的表中)
     
      --auto-generate-sql-load-type=name 
                          Specify test load type: mixed, update, write, key, or read; default is mixed.
                          (指定测试加载类型:mixed、update、write、key或read;默认为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.
                          (为自动生成SQL写入编号而要生成的唯一查询数)
     
      --auto-generate-sql-write-number=# 
                          Number of row inserts to perform for each thread (default is 100).
                          (每个线程执行的行插入数(默认值为100))
     
      --commit=#          Commit records every X number of statements.
                          (每隔x条语句提交一次记录)
     
      -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.
                          (指定测试库名称)
     
      -F, --delimiter=name 
                          Delimiter to use in SQL statements supplied in file or command line.
                          (要在文件或中提供的SQL语句中使用的分隔符命令行)
     
      -e, --engine=name   Storage engine to use for creating the table.
                          (选择查询引擎)
     
      -h, --host=name     Connect to host.
                          (主机ip/域名)
     
      -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 ifspecifying --auto-generate-sql.
                          (要在表ifspecifying中创建的varchar列数--自动生成SQL)
     
      -y, --number-int-cols=name 
                          Number of INT columns to create in table if specifying --auto-generate-sql.
                          (要在表ifspecifying中创建的int列数--自动生成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
                          (不要连接到数据库,而是打印出来)
     
      -p, --password[=name] 
                          Password to use when connecting to server.
                         (连接服务器的密码)
     
      -P, --port=#        Port number to use for connection.
                          (连接服务器的端口)
     
      --protocol=name     The protocol to use for connection (tcp, socket, pipe, memory).
                          (用于连接的协议(TCP、套接字、管道、内存))
      -q, --query=name    Query to run or file containing query to run.
                          (要运行的查询或包含要运行的查询的文件)
     
      -s, --silent        Run program in silent mode - no output.
                          (以静默模式运行程序-无输出)
     
      -S, --socket=name   The socket file to use for connection.
                          (用于连接的套接字文件)
     
      -u, --user=name     User for login if not current user.
                          (连接服务器的登陆名)
     
      -V, --version       Output version information and exit.
                          (输出版本并退出)
     

    二、使用

    单线程测试。测试做了什么。
    # mysqlslap -a -uroot -p123456
    多线程测试。使用–concurrency来模拟并发连接。
    # mysqlslap -a -c 100 -uroot -p123456
    迭代测试。用于需要多次执行测试得到平均值。
    # mysqlslap -a -i 10 -uroot -p123456
     
     
    50和100个并发分别得到一次测试结果(Benchmark),并发数越多,执行完所有查询的时间越长。为了准确起见,可以多迭代测试几次:
    # mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --debug-info -uroot -p123456

    一般测试语句的使用

    # mysqlslap --host=localhost --port=3306 --user=root --password='sss' --concurrency=100  --create-schema=aaa --query="ontest.sql"  --delimiter=";"

  • 相关阅读:
    java将string转化为int Yannis
    vm虚拟机启动报The VMware Authorization Service is not running错误 Yannis
    [org.hibernate.util.JDBCExceptionReporter] Cannot load JDBC driver class 'net. Yannis
    前台页面分页对总页数的判断 Yannis
    事务及其特性 Yannis
    iReport报表的简单函数及部分操作 Yannis
    spring aop与事务配置 Yannis
    大数据的验证和插入数据库 Yannis
    唔哇哈哈,拉霸机
    bindebug放到别的目录后不能看?编译器参数设置一下
  • 原文地址:https://www.cnblogs.com/chengyangyang/p/11821460.html
Copyright © 2020-2023  润新知