<1>建立用于基准测试用的数据库和数据库用户
create database sys_test;
grant all privileges on *.* to zhaoheng@'localhost' identified by "123456";
#给予用户所有权限
<2>生成测试数据(进入lua脚本目录,默认在/usr/local/share/sysbench/下)
sysbench oltp_read_write.lua --table-size=10000 --mysql-db=sys_test --mysql-user=zhaoheng --mysql-password=123456 --tables=10 prepare
–table-size指定表的行数
–tables对多少个表进行测试
–mysql-socket=/…/mysql.sock可以加快连接的速度(mysql.sock)
<3>测试并收集系统状态
sysbench oltp_read_write.lua --table-size=10000 --mysql-db=sys_test --mysql-user=zhaoheng --mysql-password=123456 --tables=10 run >> /tmp/sysbenchMysql.log
SQL statistics:
queries performed:
read: 25914
write: 7404
other: 3702
total: 37020
transactions: 1851 (184.94 per sec.)
queries: 37020 (3698.82 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 10.0064s
total number of events: 1851
可以看到读,写,及其他操作的数量,total是总共操作的数量,transactions是每秒执行的事务数(tps约为184),读写约为3689次
<4>、 清洗数据:(直接删除测试表当然也可以~)
sysbench oltp_read_write.lua --table-size=10000 --mysql-db=sys_test --mysql-user=zhaoheng --mysql-password=123456 --tables=10 cleanup