sysbench性能壓測(cè)以及mysql性能壓測(cè)

                sysbench性能壓測(cè)以及MySQL性能壓測(cè)

成都創(chuàng)新互聯(lián)2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元灞橋做網(wǎng)站,已為上家服務(wù),為灞橋各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108

一、Sysbench是一個(gè)模塊化的、跨平臺(tái)、多線程基準(zhǔn)測(cè)試工具,主要用于各種不同系統(tǒng)的參數(shù)下的數(shù)據(jù)庫(kù)負(fù)載情況。

 

主要測(cè)試方式






cpu性能

磁盤io性能

調(diào)度程序性能

內(nèi)存分配及傳輸速度

posix線程性能

數(shù)據(jù)庫(kù)性能(OLTP基準(zhǔn)測(cè)試)

找范圍內(nèi)最大素?cái)?shù){時(shí)間越短越好}

不同場(chǎng)景下iops{越大越好}

線程并發(fā)執(zhí)行,循環(huán)響應(yīng)信號(hào)量花費(fèi)的時(shí)間{越少越好}

以不同塊大小傳輸一定的數(shù)量的數(shù)據(jù)吞吐量大小{越大越好}

并發(fā)線程同時(shí)申請(qǐng)互斥鎖循環(huán)一定次數(shù)花費(fèi)的時(shí)間{越少越好}

qps、tps越高越好

目前sysbench主要支持MYSQL,pgsql,oracle這3種數(shù)據(jù)庫(kù)

 

二、安裝測(cè)試環(huán)境:centos6.8   mysql5.7.19

三、安裝sysbench-0.5

源碼地址https://github.com/BoobooWei/sysbench/archive/master.zip

下載到電腦桌面,然后xshell連接服務(wù)器,下載上傳軟件工具

#cd /usr/local/src/

#yum install lrzsz -y

#rz      #選中下載的軟件進(jìn)行上傳

#unzip sysbench-master.zip

#cd sysbench-master

#yum install -y automake libtool -y

#./autogen.sh

報(bào)錯(cuò):autom4te: /usr/bin/m4 failed with exit status: 63

      aclocal: autom4te failed with exit status: 63

顯示版本太低了

#查看版本信息 :yum info autoconf

#查看路徑:which autoconf

#移除低版本的:rpm -qf /usr/bin/autoconf  rpm -e --nodeps autoconf-2.63

#cd /usr/local/src

#下載新版本軟件:wgethttp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz

#tar -xzf autoconf-2.69.tar.gz

#cd autoconf-2.69

#./configure

#make && make install

#檢查版本是否正確   autoconf -V   #顯示路徑還是錯(cuò)的

#如果報(bào)錯(cuò)重新安裝如果沒有跳過  make uninstall   make clean

#./configure --prefix=/usr

#make && make install

#autoconf -V   顯示正常

#cd /usr/local/src/sysbench-master

#./autogen.sh  顯示正常

#./configure    

報(bào)錯(cuò):cannot find MySQL libraries. If you want to compile with MySQL support,缺少mysql依賴

# yum install mysql-devel -y

#./configure      顯示正常

#make && make install

四、安裝mysql5.7.19

#wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

#rpm -Uvh mysql57-community-release-el6-9.noarch.rpm

#yum install mysql-community-server

#service mysqld start

#grep 'temporary password' /var/log/mysqld.log

#mysql -uroot -p

#輸入過濾出來的密碼

#set global validate_password_policy=0;      #設(shè)置密碼復(fù)雜度

#set global validate_password_length=6;      #設(shè)置密碼長(zhǎng)度

#ALTER USER 'root'@'localhost' IDENTIFIED BY 'abc123';   #更改密碼

#create database sbtest;

#quit

 

五、測(cè)試

Mysql數(shù)據(jù)庫(kù)測(cè)試

sysbench 0.5通過一系列LUA腳本來替換之前的oltp,來模擬更接近真實(shí)的基準(zhǔn)測(cè)試環(huán)境。這些測(cè)試腳本包含:insert.lua、oltp.lua、parallel_prepare.lua、select_random_points.lua、update_index.lua、delete.luaoltp_simple.lua、select.lua、select_random_ranges.lua、update_non_index.lua,腳本使用方式基本類似。

 

sysbench 0.5默認(rèn)使用sbtest庫(kù),但是需要自己手工先創(chuàng)建好,也可以使用--mysql-db指定,其他非默認(rèn)項(xiàng)指定選項(xiàng):

 

--mysql-host

 

--mysql-port

 

--mysql-socket

 

--mysql-user

 

--mysql-password

 

--mysql-db

 

--mysql-ssl

 

prepare

 

生成表并插入數(shù)據(jù),可使用parallel_prepare.lua腳本來并行準(zhǔn)備數(shù)據(jù)。

 

-–db-driver服務(wù)器類型mysql | drizzle,默認(rèn)為mysql

 

-–mysql-table-engine表存數(shù)引擎

 

-–myisam-max-rows MyISAM表MAX_ROWS選項(xiàng)(用于大表)

 

–-oltp-table-count生成表數(shù)量[sbtest1、sbtest2...]

 

-–oltp-table-size生成表的行數(shù)

 

-–oltp-secondary ID列生成二級(jí)索引而不是主鍵

 

–-oltp-auto-inc設(shè)置ID列是否自增on | off,默認(rèn)為on --oltp-read-only=on

 

--test=sysbench-0.5/sysbench/tests目錄下測(cè)試腳本

 

sysbench \

--test=/root/sysbench-master/sysbench/tests/db/oltp.lua  \

--mysql-host=localhost  \

--mysql-port=3306  \

--mysql-user=root  \

--mysql-password=abc123 \

--oltp-table-size=100000 \

--num-threads=8 \

--max-time=10 \

--mysql-db=sbtest \

--max-requests=0 \

--oltp-test-mode=complex \

--report-interval=1 \

--mysql-table-engine=innodb  \

[prepare|run|cleanup]準(zhǔn)備/測(cè)試/清除

 

六、#測(cè)試8個(gè)線程,我的測(cè)試服務(wù)器是單核1個(gè)cpu,準(zhǔn)備

#[root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua   --mysql-host=localhost  --mysql-port=3306  --mysql-user=root --mysql-password=abc123   --oltp-table-size=100000  --num-threads=8  --max-time=10  --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex  --report-interval=1  --mysql-table-engine=innodb prepare

 

#測(cè)試

#[root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua   --mysql-host=localhost  --mysql-port=3306  --mysql-user=root --mysql-password=abc123   --oltp-table-size=100000  --num-threads=8  --max-time=10  --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex  --report-interval=1  --mysql-table-engine=innodb run

sysbench 1.0 (using bundled LuaJIT 2.1.0-beta2)

 

Running the test with following options:

Number of threads: 8

Report intermediate results every 1 second(s)

Initializing random number generator from current time

 

 

Initializing worker threads...

 

Threads started!

 

[   1s] threads: 8, tps: 149.71, reads: 2204.79, writes: 613.41, response time: 164.45ms (95%), errors: 0.00, reconnects:  0.00

[   2s] threads: 8, tps: 253.17, reads: 3543.39, writes: 1019.89, response time: 164.45ms (95%), errors: 0.00, reconnects:  0.00

[   3s] threads: 8, tps: 270.37, reads: 3784.14, writes: 1082.47, response time: 170.48ms (95%), errors: 0.00, reconnects:  0.00

[   4s] threads: 8, tps: 314.77, reads: 4402.71, writes: 1248.04, response time: 94.10ms (95%), errors: 0.00, reconnects:  0.00

[   5s] threads: 8, tps: 251.90, reads: 3528.67, writes: 1008.62, response time: 137.35ms (95%), errors: 0.00, reconnects:  0.00

[   6s] threads: 8, tps: 261.96, reads: 3670.37, writes: 1053.82, response time: 142.39ms (95%), errors: 0.00, reconnects:  0.00

[   7s] threads: 8, tps: 309.18, reads: 4328.47, writes: 1243.71, response time: 95.81ms (95%), errors: 0.00, reconnects:  0.00

[   8s] threads: 8, tps: 264.82, reads: 3701.52, writes: 1054.29, response time: 193.38ms (95%), errors: 0.00, reconnects:  0.00

[   9s] threads: 8, tps: 227.02, reads: 3185.27, writes: 919.08, response time: 179.94ms (95%), errors: 0.00, reconnects:  0.00

[  10s] threads: 8, tps: 248.11, reads: 3457.55, writes: 973.44, response time: 144.97ms (95%), errors: 0.00, reconnects:  0.00

OLTP test statistics:

    queries performed:

        read:                            35784

        write:                           10224

        other:                           5112

        total:                           51120

    transactions:                        2556   (255.33 per sec.)

    read/write requests:                 46008  (4595.97 per sec.)

    other operations:                    5112   (510.66 per sec.)

    ignored errors:                      0      (0.00 per sec.)

    reconnects:                          0      (0.00 per sec.)

 

General statistics:

    total time:                          10.1611s

    total number of events:              2556

    total time taken by event execution: 80.0554s

 

Latency statistics:

         min:                                  2.88ms

         avg:                                 31.32ms

         max:                                330.98ms

         approx.  95th percentile:           137.35ms

 

Threads fairness:

    events (avg/stddev):           319.5000/6.71

execution time (avg/stddev):   10.0069/0.00

#單核,超多線程碾壓的時(shí)候試一試64和128個(gè)線程

[root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua  --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password=abc123 --oltp-table-size=10000 --num-threads=64 --max-time=30 --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex --report-interval=1 --mysql-table-engine=innodb run

 

[root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua  --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password=abc123 --oltp-table-size=10000 --num-threads=128 --max-time=60 --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex --report-interval=1 --mysql-table-engine=innodb run

 

#清除

#[root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua   --mysql-host=localhost  --mysql-port=3306  --mysql-user=root --mysql-password=abc123   --oltp-table-size=100000  --num-threads=8  --max-time=10  --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex  --report-interval=1  --mysql-table-engine=innodb  cleanup

sysbench 1.0 (using bundled LuaJIT 2.1.0-beta2)

 

Dropping table 'sbtest1'...

 

如果是多表呢并增加表的大小,情況又會(huì)如何呢?

 [root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password=abc123 --oltp-tables-count=10 --oltp-table-size=100000 --num-threads=128 --max-time=60 --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex --report-interval=1 --mysql-table-engine=innodb prepare

 

[root@localhost sysbench-master]# sysbench --test=/usr/local/src/sysbench-master/sysbench/tests/db/oltp.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password=abc123 --oltp-tables-count=10 --oltp-table-size=100000 --num-threads=130 --max-time=20 --mysql-db=sbtest --max-requests=0 --oltp-test-mode=complex --report-interval=1 --mysql-table-engine=innodb run

 

CPU測(cè)試

 

使用64位整數(shù),測(cè)試計(jì)算素?cái)?shù)直到某個(gè)最大值所需要的時(shí)間

sysbench --test=cpu --cpu-max-prime=2000 run

 

查看CPU信息方法,查看物理cpu個(gè)數(shù)

 

grep "physical id" /proc/cpuinfo | sort -u | wc -l 查看核心數(shù)量

 

grep "core id" /proc/cpuinfo | sort -u | wc -l 查看線程數(shù)量

 

grep "processor" /proc/cpuinfo | sort -u | wc -l

 

在sysbench的測(cè)試中,--num-threads取值為"線程數(shù)量"即可

 

線程(thread)測(cè)試

 

測(cè)試線程調(diào)度器的性能。對(duì)于高負(fù)載情況下測(cè)試線程調(diào)度器的行為非常有用

sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run

 

文件IO性能測(cè)試

 

生成需要的測(cè)試文件,文件總大小5G,16個(gè)并發(fā)線程。執(zhí)行完后會(huì)在當(dāng)前目錄下生成一堆小文件

sysbench --test=fileio --num-threads=16 --file-total-size=5G prepare

 

執(zhí)行測(cè)試,指定隨機(jī)讀寫模式:

 

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

seqrewr順序重寫

seqrd順序讀取

rndrd隨機(jī)讀取

rndwr隨機(jī)寫入

rndrw混合隨機(jī)讀/寫

sysbench --test=fileio --num-threads=16 --init-rng=on --file-total-size=5G --file-test-mode=rndrw run

 

除測(cè)試文件

 

sysbench --test=fileio --num-threads=16 --file-total-size=5G cleanup

 

內(nèi)存測(cè)試

 

內(nèi)存測(cè)試測(cè)試了內(nèi)存的連續(xù)讀寫性能。

sysbench --test=memory --num-threads=16 --memory-block-size=8192 --memory-total-size=1G run

 

互斥鎖(Mutex)測(cè)試

 

測(cè)試互斥鎖的性能,方式是模擬所有線程在同一時(shí)刻并發(fā)運(yùn)行,并都短暫請(qǐng)求互斥鎖X。

sysbench --test=mutex --num-threads=16 --mutex-num=1024 --mutex-locks=10000 --mutex-loops=5000 run

 

網(wǎng)站名稱:sysbench性能壓測(cè)以及mysql性能壓測(cè)
網(wǎng)頁(yè)URL:http://muchs.cn/article30/iiocpo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、標(biāo)簽優(yōu)化、用戶體驗(yàn)、Google企業(yè)網(wǎng)站制作、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)