mysql與mariadb性能測試方法

本方法來自於阿里雲的MySQL性能白皮書,原文地址:https://help.aliyun.com/document_detail/35264.html?spm=a2c4g.11174359.6.771.pUKh2nhtml

可是我在實踐過程當中發現,一些細節部分因爲多出了空格,致使方法並不能使用,曾經提交給阿里雲客服可是沒有迴應。前端

本篇文章意在給予讀者正確的使用方法和所得結果的參數分析。mysql

 

首先建立測試機(我是在openstack雲上作的這些操做,因此是建立了trove的mysql實例,mysql實例做爲測試機能夠測試mysql和mariadb實例。),而後建立被測試機(mysql或mariadb實例)。咱們會由測試機發起測試,以得出被測試機的性能。git

 

在測試機上完成如下操做:github

下載sysbenchsql

git clone https://github.com/akopytov/sysbench.git
cd sysbench/

 


切換到0.5的分支:數據庫

git checkout -b fix-EAS-8389 remotes/origin/0.5

 


更新源(阿里源,用來下載其餘的包):ubuntu

vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

 

sudo apt-get update

 


安裝須要的包:app

sudo apt-get install libmysqlclient-dev
sudo apt-get install automake autoconf automake make libtool bzr

 

安裝sysbenchdom

./autogen.sh
./configure --prefix=/usr --mandir=/usr/share/man
make
make install

 

至此測試機上的準備工做完成,而後在被測試機上作準備工做(沒有前端管理界面的能夠自行經過mysql命令行進行建立,這裏再也不贅述)。

一、經過前端頁面在被測試機上建立一個數據庫
二、經過前端頁面在被測試機上建立一個用戶,而且賦予用戶對步驟1建立的數據庫的權限。

 

阿里測試方法
一、準備數據(注意修改mysql-host,mysql-user,mysql-password,mysql-db):

sysbench --num-threads=32 --max-time=3600 --max-requests=999999999 --test=oltp.lua --oltp-table-size=10000000 --oltp-tables-count=64 --db-driver=mysql --mysql-table-engine=innodb --mysql-host=192.168.23.128 --mysql-port=3306 --mysql-user=admin --mysql-password=123 --mysql-db=nova prepare

 

開始測試壓力性能(注意修改mysql-host,mysql-user,mysql-password,mysql-db):

sysbench --num-threads=32 --max-time=3600 --max-requests=999999999 --test=oltp.lua --oltp-table-size=10000000 --oltp-tables-count=64 --db-driver=mysql --mysql-table-engine=innodb --mysql-host=192.168.23.128 --mysql-port=3306 --mysql-user=admin --mysql-password=123 run

 

清除數據(注意修改mysql-host,mysql-user,mysql-password,mysql-db):

sysbench --num-threads=32 --max-time=3600 --max-requests=999999999 --test=oltp.lua --oltp-table-size=10000000 --oltp-tables-count=64 --db-driver=mysql --mysql-table-engine=innodb --mysql-host=192.168.111.177 --mysql-port=3306 --mysql-user=admin --mysql-password=123 --mysql-db=nova cleanup

 

結果分析:

sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 8
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored

Threads started!
– 每10秒鐘報告一次測試結果,tps、每秒讀、每秒寫、99%以上的響應時長統計
[ 10s] threads: 8, tps: 1111.51, reads/s: 15568.42, writes/s: 4446.13, response time: 9.95ms (99%)
[ 20s] threads: 8, tps: 1121.90, reads/s: 15709.62, writes/s: 4487.80, response time: 9.78ms (99%)
[ 30s] threads: 8, tps: 1120.00, reads/s: 15679.10, writes/s: 4480.20, response time: 9.84ms (99%)
[ 40s] threads: 8, tps: 1114.20, reads/s: 15599.39, writes/s: 4456.30, response time: 9.90ms (99%)
[ 50s] threads: 8, tps: 1114.00, reads/s: 15593.60, writes/s: 4456.70, response time: 9.84ms (99%)
[ 60s] threads: 8, tps: 1119.30, reads/s: 15671.60, writes/s: 4476.50, response time: 9.99ms (99%)
OLTP test statistics:
queries performed:
read: 938224 – 讀總數
write: 268064 – 寫總數
other: 134032 – 其餘操做總數(SELECT、INSERT、UPDATE、DELETE以外的操做,例如COMMIT等)
total: 1340320 – 所有總數
transactions: 67016 (1116.83 per sec.) – 總事務數(每秒事務數)TPS
deadlocks: 0 (0.00 per sec.) – 發生死鎖總數
read/write requests: 1206288 (20103.01 per sec.) – 讀寫總數(每秒讀寫次數)QPS
other operations: 134032 (2233.67 per sec.) – 其餘操做總數(每秒其餘操做次數)

General statistics: – 一些統計結果
total time: 60.0053s – 總耗時
total number of events: 67016 – 共發生多少事務數
total time taken by event execution: 479.8171s – 全部事務耗時相加(不考慮並行因素)
response time: – 響應時長統計
min: 4.27ms – 最小耗時
avg: 7.16ms – 平均耗時
max: 13.80ms – 最長耗時
approx. 99 percentile: 9.88ms – 超過99%平均耗時

Threads fairness:
events (avg/stddev): 8377.0000/44.33
execution time (avg/stddev): 59.9771/0.00

https://help.aliyun.com/document_detail/35264.html?spm=a2c4g.11174359.6.771.pUKh2n

相關文章
相關標籤/搜索