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

sysbench-0.4.12编译安装和CPU测试例子分享

程序员文章站 2024-02-29 11:21:34
一、获取安装包 最近的版本为0.4.12,下载地址: 二、编译安装 我的环境为rhel6.2 + mysql 5.6.16,搭建参考上两篇文章<

一、获取安装包

最近的版本为0.4.12,下载地址:

二、编译安装

我的环境为rhel6.2 + mysql 5.6.16,搭建参考上两篇文章<<rhel6.2编译安装mysql 5.6.16>><<mysql benchmark安装dbi组件>>,安装步骤如下:

复制代码 代码如下:

[root@beanvm ~]# tar -xvf sysbench-0.4.12.tar.gz
[root@beanvm ~]# cd sysbench-0.4.12
[root@beanvm sysbench-0.4.12]# ./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib && make && make install

因为我的mysql是编译安装的,所以上面需要给出mysql的库文件位置(对应—with—mysql-includes和–with-mysql-libs选项)。

安装过程中常见的报错如下:

复制代码 代码如下:

../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/lib: no such file or directory
../libtool: line 2403: xsysbench: command not found

在之前版本中,碰见这个问题我们只需要在编译操作前执行sysbench解压目录下的autogen.sh脚本即可;不过现在这样做还是会报同样的错误,原因是sysbench自带的libtool有问题,我们可以比较它和/usr/bin/libtool文件的区别得知,总之可以通过替换这个libtool文件来解决,或者修改aclocal.m4文件的如下内容

复制代码 代码如下:

# always use our own libtool.
libtool='$(shell) $(top_builddir)/libtool'
ac_subst(libtool)dnl

将libtool变量的值修改为:'$(shell)  /usr/bin/libtool',即使用系统的libtool工具包。

修改后再执行make && make install即可顺利安装。

安装完成马上测试一下:

复制代码 代码如下:

[root@beanvm sysbench-0.4.12]# sysbench
sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: no such file or directory

说是缺少libmysqlclient.so.18文件,额,这个文件是存在的,需要手动链接一下:

复制代码 代码如下:

[root@beanvm ~]# ls -l /usr/local/mysql/lib/libmysqlclient.so.18*
lrwxrwxrwx. 1 mysql mysql      24 feb 15 14:39 /usr/local/mysql/lib/libmysqlclient.so.18 -> libmysqlclient.so.18.1.0
-rwxr-xr-x. 1 mysql mysql 7654927 feb 15 14:30 /usr/local/mysql/lib/libmysqlclient.so.18.1.0
[root@beanvm ~]# ls -l /usr/lib/libmysqlclient.so.18*
ls: cannot access /usr/lib/libmysqlclient.so.18*: no such file or directory
[root@beanvm ~]# ln ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/

部署完成,运行一个cpu基准测试:

复制代码 代码如下:

[root@beanvm ~]# sysbench --test=cpu --cpu-max-prime=20000 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

running the test with following options:
number of threads: 1

doing cpu performance benchmark

threads started!
done.

maximum prime number checked in cpu test: 20000

test execution summary:
    total time:                          40.4541s
    total number of events:              10000
    total time taken by event execution: 40.4165
    per-request statistics:
         min:                                  3.64ms
         avg:                                  4.04ms
         max:                                 21.82ms
         approx.  95 percentile:               5.20ms

threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   40.4165/0.00