Sysbench scripts使用說明文檔

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腳本的地址)

 

發佈了34 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章