压力测试是指在MySQL上线前,需要进行大量的压力测试,从而达到交付的标准。压力测试不仅可以测试MySQL服务的稳定性,还可以测试出MySQL和系统的瓶颈。
TPCC测试:Transaction Processing Performance Council,要熟练使用
TPC是一系列事务处理和数据库基准测试的规范。其中TPC-C是针对OLTP的基准测试模型,一方面可以衡量数据库的性能,另一方面可以衡量硬件性价比,也是广泛应用并关注的一种测试模型。
TPC-C模型是以一个在线零售业为例,设计的一种模型。具体架构如下所示:
https://rensanning.iteye.com/blog/2159732?utm_source=jiancool
引用
$ sysbench --test=oltp --db-driver=mysql --mysql-password=sbtest prepare
$ sysbench --test=oltp --db-driver=mysql --mysql-password=sbtest run
结果:
引用
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
TPC-C测试模型给基准测试提供了一种统一的测试标准,并非实际应用系统中的真实测试结果,但通过测试结果,可以大体观察出MySQL数据库服务稳定性、性能以及系统性能等一系列问题。TPC-C仅仅是一个测试模型,而在实际测试中,需要参考和使用一些测试工具,对系统和MySQL数据库进行压力测试、稳定性测试。
1.安装bzr工具
[root@mysql1 /]# yum install bzr
2.下载tpcc-mysql
[root@mysql1 /]# bzr branch lp:~percona-dev/perconatools/tpcc-mysql
3.编译安装tpcc-mysql
[root@mysql1 /]# export PATH=/usr/local/mysql/bin:$PATH
[root@mysql1 /]# cd tpcc-mysql/src
[root@mysql1 src]# make
4.创建库
[mysql@mysql1 ~]$ mysqladmin -usystem -p