■■sysbench最新源码编译安装
wget https://github.com/akopytov/sysbench/archive/master.zip
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
■根据sysbench文档,需如下依赖包
yum install make automake libtool pkgconfig libaio-devel
yum install mariadb-devel openssl-devel
Error: Package: 1:mariadb-devel-5.5.68-1.el7.x86_64 (base)
Requires: mariadb-libs(x86-64) = 1:5.5.68-1.el7
以上错误可不处理,因为实际在配置PXC集群的时候,PXC的相关package已经替换了这个通用的mariadb-libs,猜测应该是sysbnench的最新版本并未匹配PXC80版本。
■编译安装
./autogen.sh
./configure
make -j
make install
■■基准测试-创建测试库sbtest
后续所有的测试都基于sbtest数据库,需要事先创建,且测试数据清理后也不会删除该库,因此只需创建1次。
CREATE DATABASE sbtest;
最后可以删除该库。
DROP DATABASE sbtest;
■■基准测试-测试方法选择
为了尽可能的还原项目生产场景,此处选用oltp_read_write标准的读写测试脚本进行压力测试,命令行方式如下:
sysbench /usr/local/share/sysbench/oltp_read_write.lua ...后面参数略,见下
prepare用于准备测试数据
准备完后,执行run来测试
测试完后,执行cleanup清除测试数据
最新版本的sysbench脚本位置如上所示,可见不同于前期的版本。
■■基准测试-prepare
sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=sbtest --mysql-user='inspur' --mysql-password='passwd' --table_size=100000 --tables=10 --threads=5 --time=120 --events=0 --report-interval=10 \
prepare
--table_size 每张表初始化的数据数量
--tables 初始化表的数量
--threads 启动的并发线程
--time 运行时间,设为0表示不限制时间
--events 最大请求数量,定义数量后可以不需要--time选项
--report-interval 运行期间日志,单位为秒
此处使用10个表,每个表有10万条数据,客户端的并发线程数为 5,执行时间为120秒,每10秒生成一次报告
并发5个线程,即模拟5个并发连接,不停的对数据库进行读写操作,连续压测120秒,即可得到详细的测试结果。
■■基准测试-run
[root@mysqldb1:1 /mysql/soft]# sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=sbtest --mysql-user='inspur' --mysql-password='passwd' --table_size=100000 --tables=10 --threads=5 --time=120 --events=0 --report-interval=10 \
> run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 5
Report intermediate results every 10 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
[ 10s ] thds: 5 tps: 216.24 qps: 4332.88 (r/w/o: 3034.11/527.76/771.00) lat (ms,95%): 29.19 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 5 tps: 280.10 qps: 5598.38 (r/w/o: 3918.56/699.41/980.41) lat (ms,95%): 28.67 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 5 tps: 292.10 qps: 5839.03 (r/w/o: 4086.42/739.20/1013.41) lat (ms,95%): 27.66 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 5 tps: 275.70 qps: 5518.10 (r/w/o: 3863.90/700.50/953.70) lat (ms,95%): 26.68 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 5 tps: 284.10 qps: 5684.07 (r/w/o: 3978.28/715.80/989.99) lat (ms,95%): 26.68 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 5 tps: 283.90 qps: 5677.91 (r/w/o: 3975.50/712.10/990.30) lat (ms,95%): 27.17 err/s: 0.00 reconn/s: 0.00
[ 70s ] thds: 5 tps: 299.90 qps: 6000.12 (r/w/o: 4198.91/759.70/1041.50) lat (ms,95%): 26.68 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 5 tps: 293.50 qps: 5869.98 (r/w/o: 4108.98/746.30/1014.70) lat (ms,95%): 26.20 err/s: 0.00 reconn/s: 0.00
[ 90s ] thds: 5 tps: 294.80 qps: 5894.61 (r/w/o: 4126.61/743.80/1024.20) lat (ms,95%): 27.66 err/s: 0.00 reconn/s: 0.00
[ 100s ] thds: 5 tps: 290.10 qps: 5803.03 (r/w/o: 4062.02/733.90/1007.10) lat (ms,95%): 26.20 err/s: 0.00 reconn/s: 0.00
[ 110s ] thds: 5 tps: 295.20 qps: 5899.99 (r/w/o: 4130.40/751.70/1017.90) lat (ms,95%): 26.20 err/s: 0.00 reconn/s: 0.00
[ 120s ] thds: 5 tps: 277.90 qps: 5562.38 (r/w/o: 3892.99/708.40/961.00) lat (ms,95%): 29.19 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 473774
write: 85387
other: 117659
total: 676820
transactions: 33841 (281.99 per sec.)
queries: 676820 (5639.70 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
Throughput:
events/s (eps): 281.9852
time elapsed: 120.0099s
total number of events: 33841
Latency (ms):
min: 5.92
avg: 17.73
max: 881.57
95th percentile: 27.17
sum: 599945.24
Threads fairness:
events (avg/stddev): 6768.2000/28.27
execution time (avg/stddev): 119.9890/0.00
以上测试结果的核心数据是:
tps: 291 每秒事务数
qps: 5830 每秒查询数
lat: 25 延迟25毫秒
这个测试结果表明,完全可以满足实际生产场景。
■■基准测试-cleanup
最后清理掉测试数据
[root@mysqldb1:1 /mysql/soft]# sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=sbtest --mysql-user='inspur' --mysql-password='passwd' --table_size=100000 --tables=10 --threads=5 --time=120 --events=0 --report-interval=10 \
> cleanup
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Dropping table 'sbtest9'...
Dropping table 'sbtest10'...
文章评论