之前介紹了相關(guān)mysql的性能參數調優(yōu),這些天利用基準測試工具對mysql的測試,Jason留下點(diǎn)Memory。
Mysql數據庫本身提供了比較優(yōu)秀的性能測試工具,這里另外介紹下sysbench。
Sysbench 主要的測試方法有:
CPU性能
磁盤(pán)IO性能
調度程序性能
內存分配及傳輸速度
POSIX線(xiàn)程性能
數據庫OLTP性能測試
其中數據庫OLTP性能測試支持Mysql,PostgreSQL和ORACLE.sysbench主要應用于Linux.
對于InnoDB存儲引擎的數據庫應用來(lái)說(shuō),我們更關(guān)心的是磁盤(pán)和OLTP性能,所以sysbench提供了相應的測試選項:
IO性能測試的fileio選項,包括prepare,run和clean三個(gè)階段。
sysbench –test=fileio –file-num=16 –file-total-size=2G prepare
上面的命令產(chǎn)生了16個(gè)文件總大小2GB
sysbench –test=fileio –file-total-size=2G –file-test-mode=rndrd –max-time=180–max-requests=100000000 –num-threads=16 –init-rng=on –file-num=16 –file-extra-flags=direct –file-fsybc-freq=0 –file-block-size=16384 run
在結果中我們關(guān)注的是讀取性能和IOPS值。
對于OLTP性能來(lái)說(shuō)和上面的步驟一樣,首先prepare,
sysbench –test=oltp –oltp-table-size=80000000 –db-driver=mysql –mysql-socket=/tmp/mysql.sock –mysql-user=root prepare
之后開(kāi)始測試:
sysbench –test=oltp –oltp-table-size=80000000 –oltp-read-only=off –init-rng=on –num-threads=16 –max-requests=0 –oltp-dist-type=uniform –max-time=3600 –mysql-user=root –db-driver=mysql –mysql-socket=/tmp/mysql.sock run > log.log
我們關(guān)注的transactions的總數及TPS。
比較重要的參數:
–file-test-mode: 文件測試順序,seqwr(順序寫(xiě)),seqrewr(順序讀寫(xiě)),seqrd(順序讀),rndrd(隨機讀),rndwr(隨機寫(xiě))和rndrw(隨機讀寫(xiě))
–file-rw-ratio : 測試時(shí)的讀寫(xiě)比例。
這樣我們就能更好的優(yōu)化我們的mysql數據庫了。原文轉自:http://kjueaiud.com