一,测试环境
centos7
mysql5.7.27
二,测试工具
SysBench是一个跨平台且支持多线程的模块化基准测试工具,用于评估系统在运行高负载的数据库时相关核心参数的性能表现。它目的是为了绕过复杂的数据库基准设置,甚至在没有安装数据库的前提下,快速了解数据库系统的性能。
安装方法
(1)下载sysbench
wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip"
unzip sysbench-1.0.zip
cd sysbench-1.0
(2)安装依赖
yum install gcc gcc-c++ autoconf automake make libtool bzr mysql-devel
(3)安装
./autogen.sh
./configure --prefix=/usr --mandir=/usr/share/man
make
make install
(4)安装成功
sysbench --version
sysbench 1.0.17
三,测试命令
1,准备数据
sysbench ./tests/include/oltp_legacy/oltp.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=xxxxxx --oltp-test-mode=complex --oltp-tables-count=10 --oltp-table-size=100000 --threads=10 --time=120 --report-interval=10 prepare
2,执行测试
sysbench ./tests/include/oltp_legacy/oltp.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=xxxxxx --oltp-test-mode=complex --oltp-tables-count=10 --oltp-table-size=100000 --threads=10 --time=120 --report-interval=10 run >> /home/mysysbench.log
3,清理数据
执行完测试后,清理数据,否则后面的测试会受到影响。
sysbench ./tests/include/oltp_legacy/oltp.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=xxxxxx cleanup
四,测试指标
TPS: Transactions Per Second,即数据库每秒执行的事务数,以commit成功次数为准。
QPS: Queries Per Second,即数据库每秒执行的SQL数(含insert、select、update、delete等)。