溫馨提示×

溫馨提示×

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

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

Mysql常用基準(zhǔn)測試命令總結(jié)

發(fā)布時間:2020-10-04 06:56:10 來源:腳本之家 閱讀:192 作者:laozhang 欄目:MySQL數(shù)據(jù)庫

mysqlslap

常用參數(shù)說明

  • –auto-generate-sql 由系統(tǒng)自動生成sql腳本進(jìn)行測試
  • –auto-generate-sql-add-autoincrement 在生成的表中增加自增ID
  • –auto-generate-sql-load-type 指定測試中使用的查詢類型
  • –auto-generate-sql-write-number 制定初始化數(shù)據(jù)時生成的數(shù)據(jù)量
  • –concurrency 指定并發(fā)線程的數(shù)量
  • –engine 指定要測試表的存儲引擎,逗號分隔多個
  • –no-drop 不清理測試數(shù)據(jù)(一般不設(shè)置)
  • –iterations 指定測試運(yùn)行的次數(shù)
  • –number-of-queries 指定每一個線程執(zhí)行的查詢數(shù)量
  • –debug-info 指定輸出額外的內(nèi)存及cpu統(tǒng)計信息
  • –number-int-cols 指定測試表中包含的int類型列的數(shù)量
  • –number-char-cols指定測試表中包含的varchar類型數(shù)量
  • –create-schema 指定用于執(zhí)行測試的數(shù)據(jù)庫名字
  • –query 用于指定自定義sql的腳本
  • –only-print 并不運(yùn)行測試腳本,而是把生產(chǎn)的腳本打印出來

mysqlslap --concurrency=1,50,100,200 --iterations=3 --number-int-cols=5 --number-char-cols=5 --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=myisam,innodb --number-of-queries=10 --create-schema=sbtest

sysbench

安裝說明

# 下載https://gihub.com/akopytov/sysbench/archive/0.5.zip# 解壓unzip sysbench-0.5zip
cd sysbench
./autogen.sh# 配置自己的mysql include 和 lib目錄./configure --with-mysql-includes=/usr/local/mysql/include/ --with-mysql-libs=/usr/local/mysql/lib/
make && make install

常用參數(shù)

–test 用于指定索要執(zhí)行的測試類型 支持一下參數(shù)

Fileio 文件系統(tǒng)I/O性能測試

cpu cpu性能測試

memory 內(nèi)存性能測試

  • –mysql-db 用于指定執(zhí)行基準(zhǔn)測試的數(shù)據(jù)庫名
  • –mysql-table-engine 用于指定所使用的存儲引擎
  • –oltp-tables-count 執(zhí)行測試的表數(shù)量
  • –oltp-table-size 指定每個表中的數(shù)據(jù)行數(shù)
  • –num-threads 制定測試的并發(fā)線程數(shù)量
  • –max-time 指定測試最大時間 s
  • –report-interval 指定間隔多長時間輸出一次統(tǒng)計信息
  • –mysql-user 指定執(zhí)行測試的mysql用戶
  • –mysql-password 密碼

prepare 用于準(zhǔn)備測試數(shù)據(jù)

run 運(yùn)行測試

cleanup 清除測試數(shù)據(jù)

# 對cpu進(jìn)行測試sysbench --test=cpu --cpu-max-prime=10000 run# 磁盤I/O測試 首先準(zhǔn)備數(shù)據(jù)要大于內(nèi)存sysbench --test=Fileio --file-total-size=1Gpreparesysbench --test=Fileio --num--threads=8 --init-rgn=on -file-total-size=1G --file-test-mode=rndrw --report-interval=1# 數(shù)據(jù)庫性能測試 建立基準(zhǔn)測試的用戶密碼數(shù)據(jù),然后進(jìn)入sysbench的test目錄下,利用lua腳本測試sysbench --test=./oltp.lua --mysql-table-engine=innodb --oltp-table-size=10000 --mysql-db=db_name --mysql-user=user_name --mysql-password=password --oltp-tables-count=10 --mysql-socket=/usr/local/mysql/data/mysql.sock prepare# 開始測試,將上述命令的prepare改為run

mysqlslap

常用參數(shù)說明

  • –auto-generate-sql 由系統(tǒng)自動生成sql腳本進(jìn)行測試
  • –auto-generate-sql-add-autoincrement 在生成的表中增加自增ID
  • –auto-generate-sql-load-type 指定測試中使用的查詢類型
  • –auto-generate-sql-write-number 制定初始化數(shù)據(jù)時生成的數(shù)據(jù)量
  • –concurrency 指定并發(fā)線程的數(shù)量
  • –engine 指定要測試表的存儲引擎,逗號分隔多個
  • –no-drop 不清理測試數(shù)據(jù)(一般不設(shè)置)
  • –iterations 指定測試運(yùn)行的次數(shù)
  • –number-of-queries 指定每一個線程執(zhí)行的查詢數(shù)量
  • –debug-info 指定輸出額外的內(nèi)存及cpu統(tǒng)計信息
  • –number-int-cols 指定測試表中包含的int類型列的數(shù)量
  • –number-char-cols指定測試表中包含的varchar類型數(shù)量
  • –create-schema 指定用于執(zhí)行測試的數(shù)據(jù)庫名字
  • –query 用于指定自定義sql的腳本
  • –only-print 并不運(yùn)行測試腳本,而是把生產(chǎn)的腳本打印出來

mysqlslap --concurrency=1,50,100,200 --iterations=3 --number-int-cols=5 --number-char-cols=5 --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=myisam,innodb --number-of-queries=10 --create-schema=sbtest

sysbench

安裝說明

# 下載https://gihub.com/akopytov/sysbench/archive/0.5.zip# 解壓unzip sysbench-0.5zip
cd sysbench
./autogen.sh# 配置自己的mysql include 和 lib目錄./configure --with-mysql-includes=/usr/local/mysql/include/ --with-mysql-libs=/usr/local/mysql/lib/
make && make install

常用參數(shù)

–test 用于指定索要執(zhí)行的測試類型 支持一下參數(shù)

Fileio 文件系統(tǒng)I/O性能測試

cpu cpu性能測試

memory 內(nèi)存性能測試

  • –mysql-db 用于指定執(zhí)行基準(zhǔn)測試的數(shù)據(jù)庫名
  • –mysql-table-engine 用于指定所使用的存儲引擎
  • –oltp-tables-count 執(zhí)行測試的表數(shù)量
  • –oltp-table-size 指定每個表中的數(shù)據(jù)行數(shù)
  • –num-threads 制定測試的并發(fā)線程數(shù)量
  • –max-time 指定測試最大時間 s
  • –report-interval 指定間隔多長時間輸出一次統(tǒng)計信息
  • –mysql-user 指定執(zhí)行測試的mysql用戶
  • –mysql-password 密碼

prepare 用于準(zhǔn)備測試數(shù)據(jù)

run 運(yùn)行測試

cleanup 清除測試數(shù)據(jù)

# 對cpu進(jìn)行測試sysbench --test=cpu --cpu-max-prime=10000 run# 磁盤I/O測試 首先準(zhǔn)備數(shù)據(jù)要大于內(nèi)存sysbench --test=Fileio --file-total-size=1Gpreparesysbench --test=Fileio --num--threads=8 --init-rgn=on -file-total-size=1G --file-test-mode=rndrw --report-interval=1# 數(shù)據(jù)庫性能測試 建立基準(zhǔn)測試的用戶密碼數(shù)據(jù),然后進(jìn)入sysbench的test目錄下,利用lua腳本測試sysbench --test=./oltp.lua --mysql-table-engine=innodb --oltp-table-size=10000 --mysql-db=db_name --mysql-user=user_name --mysql-password=password --oltp-tables-count=10 --mysql-socket=/usr/local/mysql/data/mysql.sock prepare# 開始測試,將上述命令的prepare改為run

以上就是本次分享的全部內(nèi)容,感謝大家對億速云的支持。

向AI問一下細(xì)節(jié)

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

AI