Mysql壓測工具mysqlslap 講解

來源:互聯網
上載者:User

標籤:http   io   ar   使用   sp   strong   資料   div   on   

參考文獻:

http://dev.mysql.com/doc/refman/5.1/en/mysqlslap.html

http://www.ningoo.net/html/2008/mysql_load_test_tool_mysqlslap.html

 

 

在mysql5.1以後的版本:用戶端帶了個工具mysqlslap可以對mysql進行壓力測試:

可以使用mysqlslap --help來顯示使用方法:

Default options are read from the following files in the given order: /etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf

--concurrency代表並發數量,多個可以用逗號隔開,concurrency=10,50,100, 並發連接線程數分別是10、50、100個並發。

--engines代表要測試的引擎,可以有多個,用分隔字元隔開。 --iterations代表要運行這些測試多少次。 --auto-generate-sql 代表用系統自己產生的SQL指令碼來測試。 --auto-generate-sql-load-type 代表要測試的是讀還是寫還是兩者混合的(read,write,update,mixed) --number-of-queries 代表總共要運行多少次查詢。每個客戶啟動並執行查詢數量可以用查詢總數/並發數來計算。 --debug-info 代表要額外輸出CPU以及記憶體的相關資訊。 --number-int-cols :建立測試表的 int 型欄位數量 --auto-generate-sql-add-autoincrement : 代表對產生的表自動添加auto_increment列,從5.1.18版本開始 --number-char-cols 建立測試表的 char 型欄位數量。 --create-schema 測試的schema,MySQL中schema也就是database。 --query  使用自訂指令碼執行測試,例如可以調用自訂的一個預存程序或者sql語句來執行測試。 --only-print 如果只想列印看看SQL語句是什麼,可以用這個選項。

mysqlslap -umysql -p123 --concurrency=100 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam --number-of-queries=10 --debug-info 

或:

指定資料庫和sql語句:

mysqlslap -h192.168.3.18 -P4040 --concurrency=100 --iterations=1 --create-schema=‘test‘ --query=‘select * from test;‘ --number-of-queries=10 --debug-info -umysql -p123

要是看到底做了什麼可以加上:--only-print

Benchmark         Average number of seconds to run all queries: 25.225 seconds         Minimum number of seconds to run all queries: 25.225 seconds         Maximum number of seconds to run all queries: 25.225 seconds         Number of clients running queries: 100         Average number of queries per client: 0

以上表明100個用戶端同時運行要25秒

 

再如:

mysqlslap -uroot -p123456 --concurrency=100 --iterations=1 --engine=myisam --create-schema=‘haodingdan112‘ --query=‘select *  From order_boxing_transit where id = 10‘ --number-of-queries=1 --debug-info

Mysql壓測工具mysqlslap 講解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.