1. 程式人生 > 資料庫 >Mysql常用基準測試命令總結

Mysql常用基準測試命令總結

mysqlslap

常用引數說明

  • –auto-generate-sql 由系統自動生成sql指令碼進行測試
  • –auto-generate-sql-add-autoincrement 在生成的表中增加自增ID
  • –auto-generate-sql-load-type 指定測試中使用的查詢型別
  • –auto-generate-sql-write-number 制定初始化資料時生成的資料量
  • –concurrency 指定併發執行緒的數量
  • –engine 指定要測試表的儲存引擎,逗號分隔多個
  • –no-drop 不清理測試資料(一般不設定)
  • –iterations 指定測試執行的次數
  • –number-of-queries 指定每一個執行緒執行的查詢數量
  • –debug-info 指定輸出額外的記憶體及cpu統計資訊
  • –number-int-cols 指定測試表中包含的int型別列的數量
  • –number-char-cols指定測試表中包含的varchar型別數量
  • –create-schema 指定用於執行測試的資料庫名字
  • –query 用於指定自定義sql的指令碼
  • –only-print 並不執行測試指令碼,而是把生產的指令碼打印出來

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

常用引數

–test 用於指定索要執行的測試型別 支援一下引數

Fileio 檔案系統I/O效能測試

cpu cpu效能測試

memory 記憶體效能測試

  • –mysql-db 用於指定執行基準測試的資料庫名
  • –mysql-table-engine 用於指定所使用的儲存引擎
  • –oltp-tables-count 執行測試的表數量
  • –oltp-table-size 指定每個表中的資料行數
  • –num-threads 制定測試的併發執行緒數量
  • –max-time 指定測試最大時間 s
  • –report-interval 指定間隔多長時間輸出一次統計資訊
  • –mysql-user 指定執行測試的mysql使用者
  • –mysql-password 密碼

prepare 用於準備測試資料

run 執行測試

cleanup 清除測試資料

# 對cpu進行測試sysbench --test=cpu --cpu-max-prime=10000 run# 磁碟I/O測試 首先準備資料要大於記憶體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# 資料庫效能測試 建立基準測試的使用者密碼資料,然後進入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

常用引數說明

  • –auto-generate-sql 由系統自動生成sql指令碼進行測試
  • –auto-generate-sql-add-autoincrement 在生成的表中增加自增ID
  • –auto-generate-sql-load-type 指定測試中使用的查詢型別
  • –auto-generate-sql-write-number 制定初始化資料時生成的資料量
  • –concurrency 指定併發執行緒的數量
  • –engine 指定要測試表的儲存引擎,逗號分隔多個
  • –no-drop 不清理測試資料(一般不設定)
  • –iterations 指定測試執行的次數
  • –number-of-queries 指定每一個執行緒執行的查詢數量
  • –debug-info 指定輸出額外的記憶體及cpu統計資訊
  • –number-int-cols 指定測試表中包含的int型別列的數量
  • –number-char-cols指定測試表中包含的varchar型別數量
  • –create-schema 指定用於執行測試的資料庫名字
  • –query 用於指定自定義sql的指令碼
  • –only-print 並不執行測試指令碼,而是把生產的指令碼打印出來

mysqlslap --concurrency=1,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

常用引數

–test 用於指定索要執行的測試型別 支援一下引數

Fileio 檔案系統I/O效能測試

cpu cpu效能測試

memory 記憶體效能測試

  • –mysql-db 用於指定執行基準測試的資料庫名
  • –mysql-table-engine 用於指定所使用的儲存引擎
  • –oltp-tables-count 執行測試的表數量
  • –oltp-table-size 指定每個表中的資料行數
  • –num-threads 制定測試的併發執行緒數量
  • –max-time 指定測試最大時間 s
  • –report-interval 指定間隔多長時間輸出一次統計資訊
  • –mysql-user 指定執行測試的mysql使用者
  • –mysql-password 密碼

prepare 用於準備測試資料

run 執行測試

cleanup 清除測試資料

# 對cpu進行測試sysbench --test=cpu --cpu-max-prime=10000 run# 磁碟I/O測試 首先準備資料要大於記憶體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# 資料庫效能測試 建立基準測試的使用者密碼資料,然後進入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

以上就是本次分享的全部內容,感謝大家對我們的支援。