欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql性能测试工具之sysbench

程序员文章站 2022-05-19 12:18:31
...

sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况,主要测试以下几种:(1).cpu性能(2).磁盘io性能(3).

sysbench是一个模块化的、跨平台、多线程基准测试工具,,主要用于评估测试各种不同系统参数 下的数据库负载情况,主要测试以下几种:

(1).cpu性能

(2).磁盘io性能

(3).调度程序性能

(4).内存分配及传输速度

(5).POSIX线程性能

(6).数据库性能(OLTP基准测试)

1.下载和安装sysbench工具

[root@centos179min home]# wget

[root@centos179min home]# cd sysbench-0.4.10

[root@centos179min sysbench-0.4.10]# ./configure --help | grep mysql --自己仔细查看安装帮助
--with-mysql compile with MySQL support (default is enabled)
--with-mysql-includes path to MySQL header files
--with-mysql-libs path to MySQL libraries
Report bugs to alexeyk@mysql.com.

[root@centos179min sysbench-0.4.10]# ./configure --prefix=/usr/local/sysbench-0.4.10 --with-mysql --with-mysql-includes=/usr/local/mysql-5.7.4-m14-linux/include/ --with-mysql-libs=/usr/local/mysql-5.7.4-m14-linux/lib/

[root@centos179min sysbench-0.4.10]# make --这时如果以下错误

drv_mysql.c: In function 'mysql_drv_store_results':
drv_mysql.c:784: error: 'MYSQL' undeclared (first use in this function)
drv_mysql.c:784: error: 'con' undeclared (first use in this function)
drv_mysql.c:785: error: 'MYSQL_RES' undeclared (first use in this function)
drv_mysql.c:785: error: 'res' undeclared (first use in this function)
drv_mysql.c:786: error: 'MYSQL_ROW' undeclared (first use in this function)
drv_mysql.c:786: error: expected ';' before 'row'
drv_mysql.c:834: error: 'ER_LOCK_DEADLOCK' undeclared (first use in this function)
drv_mysql.c:834: error: 'ER_LOCK_WAIT_TIMEOUT' undeclared (first use in this function)
drv_mysql.c:850: error: 'row' undeclared (first use in this function)
drv_mysql.c: In function 'mysql_drv_free_results':
drv_mysql.c:874: error: 'MYSQL_RES' undeclared (first use in this function)
drv_mysql.c:874: error: expected expression before ')' token
make[3]: *** [libsbmysql_a-drv_mysql.o] Error 1
make[3]: Leaving directory `/home/sysbench-0.4.10/sysbench/drivers/mysql'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/sysbench-0.4.10/sysbench/drivers'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sysbench-0.4.10/sysbench'
make: *** [all-recursive] Error 1

[root@centos179min sysbench-0.4.10]# yum install mysql-devel --解决方法,安装mysql-devel开发包

[root@centos179min sysbench-0.4.10]# rpm -ql mysql-devel | grep include --查看开发包的路径

[root@centos179min sysbench-0.4.10]# ./configure --prefix=/usr/local/sysbench-0.4.10 --with-mysql --with-mysql-includes=/usr/include/mysql/ --with-mysql-libs=/usr/local/mysql-5.7.4-m14-linux/lib/mysql

[root@centos179min sysbench-0.4.10]# make --这时如果再有以下错误

../libtool: line 841: X--tag=CC: command not found
../libtool: line 874: libtool: ignoring unknown tag : command not found
../libtool: line 841: X--mode=link: command not found
../libtool: line 1007: *** Warning: inferring the mode of operation is deprecated.: command not found
../libtool: line 1008: *** Future versions of Libtool will require --mode=MODE be specified.: command not found
../libtool: line 2234: X-g: command not found
../libtool: line 2234: X-O2: command not found
../libtool: line 1954: X-L/usr/local/mysql-5.7.4-m14-linux/lib/mysql: No such file or directory
../libtool: line 2403: Xsysbench: command not found
../libtool: line 2408: X: command not found
../libtool: line 2415: Xsysbench: command not found
../libtool: line 2550: X-lmysqlclient_r: command not found
../libtool: line 2550: X-lrt: command not found
../libtool: line 2550: X-lm: command not found
../libtool: line 2632: X-L/home/sysbench-0.4.10/sysbench: No such file or directory
../libtool: line 2550: X-lmysqlclient_r: command not found
../libtool: line 2550: X-lrt: command not found
../libtool: line 2550: X-lm: command not found
../libtool: line 2632: X-L/home/sysbench-0.4.10/sysbench: No such file or directory

[root@centos179min sysbench-0.4.10]# vim libtool --解决方法(将libtool文件中的"ECHO="改为"echo=")

ECHO="echo" 修改为 echo="echo"

[root@centos179min sysbench-0.4.10]# make --此时不会再有错误了

[root@centos179min sysbench-0.4.10]# make install

[root@centos179min sysbench-0.4.10]# echo $? --检查是否安装成功
0

[root@centos179min sysbench-0.4.10]# ll /usr/local/sysbench-0.4.10/bin/
total 288
-rwxr-xr-x. 1 root root 293649 Oct 8 20:00 sysbench
[root@centos179min sysbench-0.4.10]#

2.测试CPU的性能