溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

mysql sysben0.5的安裝和測試步驟

發(fā)布時間:2021-09-04 09:30:50 來源:億速云 閱讀:144 作者:chen 欄目:MySQL數(shù)據(jù)庫

這篇文章主要介紹“mysql sysben0.5的安裝和測試步驟”,在日常操作中,相信很多人在mysql sysben0.5的安裝和測試步驟問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”mysql sysben0.5的安裝和測試步驟”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

安裝sysbench 

OS readhat 6.4

mysql版本5.7

mysql安裝目錄

下載安裝包 https://github.com/akopytov/sysbench

shell> wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip"

2. 安裝依賴包 

# yum -y install  make automake libtool pkgconfig libaio-devel vim-common

3、上傳到linux系統(tǒng)中(/usr/local/),并且解壓,進入/usr/local/執(zhí)行:

p unzip sysbench-0.5.zip -d  /usr/local

4、創(chuàng)建sysbench安裝目錄文件夾:

5、進入/usr/local/sysbench-master/執(zhí)行:./autogen.sh

# cd /usr/local/sysbench-0.5

# ./autogen.sh

6.

#./configure --prefix=/usr/local/sysbench-0.5 --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib/;

7.

#  make

8.

# make install

9.查看版本

[root@msyqlzhu sysbench-0.5]# /usr/local/sysbench-0.5/bin/sysbench version

sysbench 0.5

如果出現(xiàn):(sysbench: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory)報錯,

則在(vim /etc/profile 中加入:export LD_LIBRARY_PATH=/usr/local/mysql/lib/)

常用參數(shù): 

#-test=tests/db/oltp.lua 表示調(diào)用 tests/db/oltp.lua 腳本進行 oltp 模式測試

#--oltp_tables_count=10 表示會生成 10 個測試表

#--oltp-table-size=100000 表示每個測試表填充數(shù)據(jù)量為 100000 

#--rand-init=on 表示每個測試表都是用隨機數(shù)據(jù)來填充的

#-num-threads=8 表示發(fā)起 8個并發(fā)連接

#--oltp-read-表示不要進行只讀測試,也就是會采用讀寫混合模式測試

#--report-interval=10 表示每10秒輸出一次測試進度報告

#--rand-type=uniform 表示隨機類型為固定模式,其他幾個可選隨機模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)

#--max-time=120 表示最大執(zhí)行時長為 120秒

#--max-requests=0 表示總請求數(shù)為 0,因為上面已經(jīng)定義了總執(zhí)行時長,所以總請求數(shù)可以設(shè)定為 0;也可以只設(shè)定總請求數(shù),不設(shè)定最大執(zhí)行時長

#--percentile=99 表示設(shè)定采樣比例,默認是 95%,即丟棄1%的長請求,在剩余的99%里取最大值

測試文件IO

測試cpu的CPU測試使用64位整數(shù),測試計算素數(shù)直到某個最大值所需要的時間。

# /usr/local/sysbench-0.5/bin/sysbench --test=cpu --cpu-max-prime=20000 run

 General statistics:

    total time:                          26.8631s

    total number of events:              10000

    total time taken by event execution: 26.8434s

    response time:

         min:                                  2.24ms

         avg:                                  2.68ms

         max:                                  7.49ms

         approx.  95 percentile:               3.20ms

Threads fairness:

    events (avg/stddev):           10000.0000/0.00

    execution time (avg/stddev):   26.8434/0.00

1.測試線程

[root@msyqlzhu t]# /usr/local/sysbench-0.5/bin/sysbench --test=threads --num-threads=64 run 

sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 64

Random number generator seed is 0 and will be ignored

Initializing worker threads...

Threads started!

General statistics:

    total time:                          5.2132s

    total number of events:              10000

    total time taken by event execution: 332.6492s

    response time:

         min:                                  0.23ms

         avg:                                 33.26ms

         max:                                282.98ms

         approx.  95 percentile:              87.66ms

Threads fairness:

    events (avg/stddev):           156.2500/5.53

    execution time (avg/stddev):   5.1976/0.01

2.互斥鎖測試互斥鎖(mutex)

/usr/local/sysbench-0.5/bin/sysbench --test=mutex --num-threads=16 --mutex-num=2048 --mutex-locks=1000000 --mutex-loops=5000 run

sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 16

Random number generator seed is 0 and will be ignored

Initializing worker threads...

Threads started!

General statistics:

    total time:                          2.5536s

    total number of events:              16

    total time taken by event execution: 39.6446s

    response time:

         min:                               2348.59ms

         avg:                               2477.79ms

         max:                               2553.24ms

         approx.  95 percentile:            2549.79ms

Threads fairness:

    events (avg/stddev):           1.0000/0.00

    execution time (avg/stddev):   2.4778/0.07

3.內(nèi)存測試

 [root@msyqlzhu ~]# /usr/local/sysbench-0.5/bin/sysbench --test=memory --memory-block-size=8K --memory-total-size=1G  --num-threads=16 run

4. 文件IO基準測試

 共1G

 [root@msyqlzhu ~]# /usr/local/sysbench-0.5/bin/sysbench --test=fileio --file-total-size=1G prepare

 1073741824 bytes written in 8.15 seconds (125.60 MB/sec).

 測試文件IO 4個文件共4G

 [root@msyqlzhu ~]#  /usr/local/sysbench-0.5/bin/sysbench --test=fileio --file-num=4 --file-total-size=4G prepare

 4261412864 bytes written in 6.52 seconds (623.68 MB/sec).

 測試文件IO 4個文件共4G.塊大小為16K

 [root@msyqlzhu ~]#  /usr/local/sysbench-0.5/bin/sysbench --test=fileio --file-num=4 --file-block-size=16384 --file-total-size=4G prepare

這個命令會在當前工作目錄下創(chuàng)建測試文件,后續(xù)的運行(run)階段將通過讀寫這些文件進行測試。 第二步就是運行(run)階段,針對不同的IO 類型有不同的測試選項:

seqwr 順序?qū)懭?/p>

seqrewr 順序重寫

seqrd 順序讀取

rndrd 隨機讀取

rndwr 隨機寫入

rndrw 混合隨機讀/寫

下面的命令運行文件I/O混合隨機讀/寫基準測試:

混合隨機讀/寫

/usr/local/sysbench-0.5/bin/sysbench --test=fileio --file-total-size=4G --file-test-mode=rndrw  --init-rng=on --max-time=300 --max-requests=0 run

清除測試的文件

/usr/local/sysbench-0.5/bin/sysbench --test=fileio --fil-total-size=30G cleanup

測試oltp

1.找到select.lua腳本路徑

[root@msyqlzhu t]# find / -name oltp.lua

/usr/local/sysbench-0.5/sysbench/tests/db/oltp.lua

2.創(chuàng)建測試的時候默認用sbtest庫

> create database sbtest;

3.prepare生成數(shù)據(jù)和表

使用的參數(shù)

--oltp-table-size 生成的表的記錄數(shù)

--oltp-tables-count生成的表的個數(shù)

# /usr/local/sysbench-0.5/bin/sysbench --test=/usr/local/sysbench-0.5/sysbench/tests/db/oltp.lua  --oltp-table-size=100000  --mysql-user=root --oltp-tables-count=10 --mysql-password=ORACLE --mysql-socket=/mysqldata/mysql/data/mysql.sock prepare

4.run運行

也可使用parallel_prepare.lua腳本并行準備測試數(shù)據(jù), 

運行時使用的參數(shù)

--oltp-dist-pct 熱點數(shù)據(jù)的比例

--oltp-dist-res 熱點數(shù)據(jù)訪問頻率

--num-threads   線程數(shù)

--max-time=3000   執(zhí)行時間

--report-interval  打印報告的時間間隔

# /usr/local/sysbench-0.5/bin/sysbench --test=/usr/local/sysbench-0.5/sysbench/tests/db/oltp.lua --num-threads=20 --oltp-dist-pct=1  --oltp-dist-res=75 --oltp-table-size=100000  --num-threads=100 --mysql-db=sbtest  --mysql-user=root --oltp-tables-count=10 --max-time=3000 --max-requests=0 --report-interval=3 --mysql-password=ORACLE  --mysql-socket=/mysqldata/mysql/data/mysql.sock run

生成的報告,tps:約為495,響應(yīng)時間response time約為380毫秒,qps約為6千多

[ 141s] threads: 100, tps: 481.38, reads: 6728.28, writes: 2001.18, response time: 369.82ms (95%), errors: 0.33, reconnects:  0.00

[ 144s] threads: 100, tps: 495.94, reads: 6958.09, writes: 1970.41, response time: 339.89ms (95%), errors: 0.00, reconnects:  0.00

[ 147s] threads: 100, tps: 513.72, reads: 7193.10, writes: 2076.22, response time: 326.33ms (95%), errors: 0.33, reconnects:  0.00

[ 150s] threads: 100, tps: 494.33, reads: 6921.66, writes: 1971.33, response time: 333.44ms (95%), errors: 0.33, reconnects:  0.00

[ 153s] threads: 100, tps: 441.32, reads: 6032.87, writes: 1685.30, response time: 396.06ms (95%), errors: 0.00, reconnects:  0.00

[ 156s] threads: 100, tps: 502.62, reads: 7007.69, writes: 2000.82, response time: 398.92ms (95%), errors: 0.00, reconnects:  0.00

[ 159s] threads: 100, tps: 428.68, reads: 6192.48, writes: 1805.71, response time: 365.53ms (95%), errors: 0.00, reconnects:  0.00

[ 162s] threads: 100, tps: 438.70, reads: 6140.14, writes: 1777.47, response time: 586.58ms (95%), errors: 0.33, reconnects:  0.00

[ 165s] threads: 100, tps: 495.63, reads: 6928.11, writes: 1951.51, response time: 380.04ms (95%), errors: 0.00, reconnects:  0.00

5.clearnup

# /usr/local/sysbench-0.5/bin/sysbench --test=/usr/local/sysbench-0.5/sysbench/tests/db/oltp.lua  --oltp-table-size=100000 --mysql-db=sbtest --mysql-user=root --oltp-tables-count=10 --mysql-password=ORACLE --mysql-socket=/mysqldata/mysql/data/mysql.sock cleanup

測試select 

1.prepare生成數(shù)據(jù)

# /usr/local/sysbench-0.5/bin/sysbench --test=/usr/local/sysbench-0.5/sysbench/tests/db/select.lua  --oltp-table-size=10000000  --mysql-user=root --oltp-tables-count=10 --mysql-password=ORACLE --mysql-socket=/mysqldata/mysql/data/mysql.sock prepare

2.run運行

運行時使用的參數(shù)

--oltp-dist-pct 熱點數(shù)據(jù)的比例

--oltp-dist-res 熱點數(shù)據(jù)訪問頻率

--num-threads   線程數(shù)

--max-time=3000   執(zhí)行時間

--report-interval  打印報告的時間間隔

打印的報告種的reads表示qps,response time表示響應(yīng)時間

# /usr/local/sysbench-0.5/bin/sysbench --test=/usr/local/sysbench-0.5/sysbench/tests/db/select.lua --num-threads=20 --oltp-dist-pct=1  --oltp-dist-res=75 --oltp-table-size=100000  --num-threads=10 --mysql-db=sbtest  --mysql-user=root --oltp-tables-count=10 --max-time=3000 --max-requests=0 --report-interval=3 --mysql-password=ORACLE  --mysql-socket=/mysqldata/mysql/data/mysql.sock run

[  84s] threads: 100, tps: 0.00, reads: 22529.11, writes: 0.00, response time: 0.14ms (95%), errors: 0.00, reconnects:  0.00

[  87s] threads: 100, tps: 0.00, reads: 22455.45, writes: 0.00, response time: 0.14ms (95%), errors: 0.00, reconnects:  0.00

[  90s] threads: 100, tps: 0.00, reads: 22569.36, writes: 0.00, response time: 0.13ms (95%), errors: 0.00, reconnects:  0.00

[  93s] threads: 100, tps: 0.00, reads: 21957.72, writes: 0.00, response time: 0.15ms (95%), errors: 0.00, reconnects:  0.00

[  96s] threads: 100, tps: 0.00, reads: 21588.06, writes: 0.00, response time: 0.14ms (95%), errors: 0.00, reconnects:  0.00

cleanup

# /usr/local/sysbench-0.5/bin/sysbench --test=/usr/local/sysbench-0.5/sysbench/tests/db/select.lua --oltp-dist-pct=1  --oltp-dist-res=75 --oltp-table-size=100000  --num-threads=10 --mysql-db=sbtest  --mysql-user=root --oltp-tables-count=10 --mysql-password=ORACLE  --mysql-socket=/mysqldata/mysql/data/mysql.sock cleanup

常用參數(shù):

Run的時候常用的參數(shù)

–oltp-tables-count

–oltp-read-only 僅執(zhí)行SELECT測試 on | off,默認為off

–oltp-dist-type 隨機數(shù)分布狀態(tài)。uniform(均勻分布)、gauss(高斯分布)、special(特殊分布)

–oltp-dist-pct 特殊分布的百分比值

–oltp-dist-res 特殊分布的百分比

–oltp-point-selects 單個事務(wù)中指定的selec查詢個數(shù)

–oltp-range-size 范圍查詢的范圍大小,該值應(yīng)比oltp-table-size小

–oltp-simple-ranges 單個事務(wù)中指定的簡單范圍查詢個數(shù)

–oltp-sum-ranges 單個事務(wù)中指定的SUM范圍查詢個數(shù)

–oltp-order-ranges 單個事務(wù)中指定的ORDER范圍查詢個數(shù)

–oltp-distinct-ranges 單個事務(wù)中指定的DISTINCT范圍查詢個數(shù)

–oltp-index-updates 單個事務(wù)中指定的使用索引更新的個數(shù)

–oltp-non-index-updates 單個事務(wù)中指定的不使用索引更新的個數(shù)

到此,關(guān)于“mysql sysben0.5的安裝和測試步驟”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI