1、 bulk_insert.lua 批量写入操作2、 oltp_common.lua oltp公用代码3、 oltp_delete.lua 写入和删除并行操作4、 oltp_insert.lua 纯写入操作5、 oltp_point_select.lua 只读操作,条件为唯一索引列6、 oltp_read_only.lua 只读操作,包含聚合,去重等操作7、 oltp_read_write.lua 读写稠浊操作,最常用的脚本8、 oltp_update_index.lua 更新操作,通过主键进行更新9、 oltp_update_non_index.lua 更新操作,不通过索引列10、 oltp_write_only.lua 纯写操作,常用脚本,包括insert update delete11、 select_random_points.lua 随机凑集只读操作,常用脚本,聚拢索引列的selete in操作12、 select_random_ranges.lua 随机范围只读操作,常用脚本,聚拢索引列的selete between操作参数解释

-–db-driver:用到的数据库类型-–mysql-host:数据库的IP-–mysql-port:数据库的端口-–mysql-socket:socket的路径-–mysql-user:数据库用户名-–mysql-password:用户密码-–mysql-db:数据库名字,默认为sysbench,须要提前创建创好-–tables:天生表的个数-–table-size:每个表的行数-–report-interval:每隔多久在屏幕打印一次信息-–time:压测韶光-–threads:启动多少个线程,即仿照多少个用户帮助命令 sysbench /usr/share/sysbench/oltpreadwrite.lua help

oltp_read_write.lua options: --auto_inc[=on|off] Use AUTO_INCREMENT column as Primary Key (for MySQL), or its alternatives in other DBMS. When disabled, use client-generated IDs [on] --create_secondary[=on|off] Create a secondary index in addition to the PRIMARY KEY [on] --delete_inserts=N Number of DELETE/INSERT combinations per transaction [1] --distinct_ranges=N Number of SELECT DISTINCT queries per transaction [1] --index_updates=N Number of UPDATE index queries per transaction [1] --mysql_storage_engine=STRING Storage engine, if MySQL is used [innodb] --non_index_updates=N Number of UPDATE non-index queries per transaction [1] --order_ranges=N Number of SELECT ORDER BY queries per transaction [1] --pgsql_variant=STRING Use this PostgreSQL variant when running with the PostgreSQL driver. The only currently supported variant is 'redshift'. When enabled, create_secondary is automatically disabled, and delete_inserts is set to 0 --point_selects=N Number of point SELECT queries per transaction [10] --range_selects[=on|off] Enable/disable all range SELECT queries [on] --range_size=N Range size for range SELECT queries [100] --secondary[=on|off] Use a secondary index in place of the PRIMARY KEY [off] --simple_ranges=N Number of simple range SELECT queries per transaction [1] --skip_trx[=on|off] Don't start explicit transactions and execute all queries in the AUTOCOMMIT mode [off] --sum_ranges=N Number of SELECT SUM() queries per transaction [1] --table_size=N Number of rows per table [10000] --tables=N Number of tables [1]数据库压力测试常日三个阶段,准备数据、压测数据、清理数据第一阶段数据准备

mysql -uroot -p123 -e \公众create database sbtest;\公众 -- 创建测试数据库sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --threads=4 prepare

登录数据库检讨天生表和数据情形

第二阶段数据运行测试

情形1:查询sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --report-interval=10 --threads=128 --time=600 ru

phpmysql压力测试mysql若何进行压力测试 Ruby

备注:主要指标

QPS(Query per second) 每秒查询量:21021.78

TPS(Transaction per second)每秒事务量 1052.19

情形2: 在每个查询的事物里面添加 INSERT/UPDATE/DELDETE 操作sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --delete_inserts=10 --index_updates=10 --non_index_updates=10 --report-interval=10 --threads=4 --time=60 run

第三阶段删除测试数据

sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --delete_inserts=10 --index_updates=10 --non_index_updates=10 --report-interval=10 --threads=4 --time=60 cleanup

注一个缺点处理(修正自己安装mysql对应socket文件)