Sysbench scripts使用说明文档

来源:互联网 发布:吃鸡优化差 编辑:程序博客网 时间:2024/05/17 07:36

Sysbench scripts使用说明文档

 

目的

基于sysbench测试工具,对其oltp测试进行自动化的封装。主要封装目的包括不同用户线程数、多次相同环境测试情况下进行自动化的测试,并对测试过程进行数据采集及分析,从很大程度上提高了测试的自动化。

 

运行依赖

运行sysbench scripts依赖主要包括mysql和sysbench。确定测试环境安装了mysql数据库,由于脚本运行中会自动启动和关闭数据库,以保证测试环境的一致性。因此,该脚本仅支持本机测试,不支持远程mysql数据库服务器的测试。sysbench安装和使用说明,参照sysbench使用说明和sysbench manual的相关内容。

 

使用说明

1、测试脚本(run.sh)

执行脚本如下所示,在script目录下,执行以下命令即可。通过-?或--help查看所有的参数选项及各个参数的默认值。

./run.sh [configure-options]

 

configure-options参数说明:

参数选项

参数解释

-?, --help

Show this help message.

--mysqldir=<>

Set the mysql home directory

--sysbenchdir=<>

Set the sysbench directory

--defaults-file=<>

Set the configure file for mysql

--host=<>

Set the host name.

--port=<>

Set the port number.

--database=<>

Set the database to sysbench.

--user=<>

Set the user name.

--password=<>

Set the password.

--socket=<>

Set the socket file

--tablesize=<>

Set the table seize.

--engine=<>

Set the sysbench engine.

--min-threads=<>

Set the min threads number.

--max-threads=<>

Set the max threads number.

--max-requests=<>

Set the max requests number.

--max-time=<>

Set the max time number.

--step=<>

Set the thread incremental step.

--var=<>

Set the variable to test.

--value=<>

Set the value of the variable.

--interval=<>

Set the interval time

--count=<>

Set the count of test.

-p,--prepare,--prepare=<>

Set the prepare procedure.

-c,--cleanup,--cleanup=<>

Set the cleanup procedure.

-r,--run,--run=<>

Set the run procedure.

-s,--server,--server=<>

Set the server whether start and shutdown within the test or not.

--outputdir=<>

Set the output directory.

 

configure-options参数默认值:

参数选项

默认值

mysqldir

/opt/Percona-Server

sysbenchdir

/opt/sysbench

defaults-file

/opt/Percona-Server/etc/my.cnf

host

localhost

port

3306

database

test

user

root

password

“”

socket

/tmp/mysql.sock

tablesize

10000

engine

innodb

min-threads

100

max-threads

1000

max-requests

10000

max-time

1000

step

100

var

“full”

value

“default”

interval

1

count

1

prepare

TRUE

cleanup

TRUE

run

TRUE

server

TRUE

outputdir

/opt/output/20120510042957

       

注意:执行脚本时,需要重点指定的参数有:max-theads、min-threads、step、count,这些值指定了测试的线程数和测试的次数。需要重点确认的参数:mysqldir、sysbenchdir、defaults-file、user、password、socket,这些参数根据安装mysql数据库和sysbench的路径相关。需要根据测试环境给出的参数:tablesize、max-requests、interval,这些参数决定了数据表的大小、最大请求数和数据采集的时间间隔,如果测试时间较长,interval建议设置的一个相对较大的值。

 

2、分析脚本(analyze.sh)

执行脚本如下所示,在script目录下,执行以下命令即可。通过-?或--help查看所有的参数选项及各个参数的默认值。

./analyze.sh [configure-options]

 

configure-options参数说明:

参数选项

参数解释

-?, --help

Show this help message.

--inputdir=<>

Set the input file path.

--min-threads=<>

Set the min threads number.

--max-threads=<>

Set the max threads number.

--step=<>

Set the thread incremental step.

--count=<>

Set the count of test.

--outputdir=<>

Set the output directory.

 

configure-options参数默认值:

参数选项

默认值

inputdir

“”

min-threads

100

max-threads

1000

step

100

count

1

outputdir

/opt/result

 

注意:执行脚本时,必须指定输入路径,如果没有给定输入参数,将会异常终止脚本。需要确定的参数:min-threads、max-threads、step、count,这些值要与执行run.sh脚本时的输入参数一致,否则会对执行run.sh过程采集的数据不能全面分析。

 

3、子文件脚本

         在脚本文件夹中有test和analyze文件夹,包含测试和分析的子文件。这些文件都可以单独执行,可以通过执行-?/--help方式查看相应的参数,并且所有的参数全部包含在以上列表中。

        

常见问题

1、在运行时,经常会出现缺少libmysqlclient*库的问题。

解决方法:

1) 拷贝mysql目录lib下的libmysqlclient库到/usr/lib(/usr/lib64,64位系统);

cp $MYSQL_HOME/lib/libmysqlclient* /usr/lib (/usr/lib64)

2)在LD_LIBRARY_PATH中声明mysql的lib目录地址

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/$MYSQL_HOME/lib

2、在运行时,找不到执行脚本。

解决方法:增加执行权限。

chmod 755 -R $SCRIPT_DIR  ($SCRIPT_DIR:指定sysbench脚本的地址)

 

原创粉丝点击