sysbench是一款测试工具主要包括以下几种方式的测试: 1、cpu性能 2、磁盘io性能 3、调度程式性能 4、内存分配及传输速度 5、POSIX线程性能 6、数据库性能(OLTP基准测试)现在sysbench主要支持 MySQL,pgsql,oracle 这3种数据库,默认支持MySQL,想要支持pgsql和oracle需要在编译时指定参数

环境介绍

名称 版本
sysbench软件版本 sysbench 0.5
操作系统 rhel 6.5
Oracle 11.2.0.4

安装

1.安装依赖包

yum -y install make m4  autoconf automake libtool pkgconfig libaio-devel

2.配置环境变量,使用实际的ORACLE_HOME目录

export CC=cc
export CXX=c++
export CFLAGS="-m64 -I /oracle/db11g/rdbms/public"
export CXXFLAGS="$CFLAGS"
export ORACLE_HOME=/oracle/db11g
export LD_LIBRARY_PATH=/oracle/db11g/lib

3.解压sysbench软件

tar -zxvf sysbench-0.5.tar.gz

4.运行autogen.sh,生成configure目录

cd /sysbench-0.5
./autogen.sh

5.编译参数配置,加上--with-oracle

./configure --prefix=/usr/local/sysbench --with-oracle --libdir=/oracle/db11g/lib --without-mysql

6.编译及安装,注意这里要带上oracle的一个so

make ORA_LIBS=/oracle/db11g/lib/libclntsh.so
make install

7.设置sysbench到path环境变量

echo "export PATH=$PATH:/usr/local/sysbench/bin">>/etc/profile
source /etc/profile

8.验证安装是否成功 WPS图片.png 9.lua文件在sysbench解压目录下sysbench/tests/db WPS图片1.png

测试使用

1.创建测试用户

create user sysbench identified by sysbench default tablespace users;
grant connect,resource to sysbench;

2.准备数据,lua文件需要指定绝对路径

sysbench --test=/root/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=oracle --oltp-table-name=sysbench --oltp-table-size=100000 --oltp-tables-count=8 --oracle-db=ucpaydb --oracle-user=sysbench --oracle-password=sysbench --max-time=60 --max-requests=10000000 --num-threads=2 --report-interval=1 prepare

WPS图片2.png 如果报错Unknown database driver: oracle,可以从https://github.com/osdba/sysbench_lua下载lua文件,解压后,将里面的lua文件全部替换到/usr/local/sysbench/share/sysbench/中,再执行就好了 WPS图片3.png 3.跑测试数据

sysbench --test=/root/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=oracle --oltp-table-name=sysbench --oltp-table-size=100000 --oltp-tables-count=8 --oracle-db=ucpaydb --oracle-user=sysbench --oracle-password=sysbench --max-time=60 --max-requests=10000000 --num-threads=2 --report-interval=1 run

WPS图片4.png WPS图片5.png 4.清理测试数据

sysbench --test=/root/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=oracle --oltp-table-name=sysbench --oltp-table-size=100000 --oltp-tables-count=8 --oracle-db=ucpaydb --oracle-user=sysbench --oracle-password=sysbench --max-time=60 --max-requests=10000000 --num-threads=2 --report-interval=1 cleanup

WPS图片6.png