搜尋
首頁資料庫mysql教程Sysbench介绍与使用

最近用sysbench进行了较多的性能测试,也总结一下它的特点和用法和需要注意的事项。sysbench是一个多线程性能测试工具,可以进行

最近用sysbench进行了较多的性能测试,也总结一下它的特点和用法和需要注意的事项。sysbench是一个多线程性能测试工具,可以进行CPU/内存/IO/数据库等性能测试。不过我绝大多数的时候都是用它来对数据库(MySQL)进行oltp测试。它能测哪些东西,怎么测让我从它的命令帮助来回答。

~/zbs$ sysbench --help 
Missing required command argument. 
Usage: 
  sysbench [general-options]... --test= [test-options]... command 

上面就大概的用法,--test=指定我们需要测什么类型,那么--test有哪几种类型呢?fileio/cpu/memory/threads/mutex,不好意思前面这几个我都没测过,我主要是用它来测数据库的性能,,但为什么没有数据库这个选项呢,这是我是用了最新的版本0.5,它与0.4的版本最大区别在于支持多表测试,执行实时打印统计信息,支持自定义lua脚本来设置测试行为。

Compiled-in tests: 
  fileio - File I/O test 
  cpu - CPU performance test 
  memory - Memory functions speed test 
  threads - Threads subsystem performance test 
  mutex - Mutex performance test 

如果你用sysbench0.4大概会看到如下,请注意oltp这个选项就是测数据库用的。

Compiled-in tests: 
  fileio - File I/O test 
  cpu - CPU performance test 
  memory - Memory functions speed test 
  threads - Threads subsystem performance test 
  mutex - Mutex performance test 
  oltp - OLTP test 

看完了测试模式之后,那么它有一些什么主要的其他控制参数呢?首先说这个每个测试模式自己特有的参数怎么擦看 sysbench --test= help,比如我这里(请注意,由于sysbench0.5的--test选项对数据库的测试不再使用oltp这个选项而是通过指定lua脚本,因此利用前面这个命令查看不到下面的结果,所以如果要查看还是通过0.4的吧,如果谁找到了方式在0.5版本里查看oltp的参数也请告诉一下。另外虽然0.5与0.4版本不同但是参数还是基本上保持兼容的):

~$ sysbench --test=oltp help 
sysbench 0.4.12:  multi-threaded system evaluation benchmark 
 
oltp options: 
  --oltp-test-mode=STRING        test type to use {simple,complex,nontrx,sp} [complex] 
  --oltp-reconnect-mode=STRING    reconnect mode {session,transaction,query,random} [session] 
  --oltp-sp-name=STRING          name of store procedure to call in SP test mode [] 
  --oltp-read-only=[on|off]      generate only 'read' queries (do not modify database) [off] 
  --oltp-skip-trx=[on|off]        skip BEGIN/COMMIT statements [off] 
  --oltp-range-size=N            range size for range queries [100] 
  --oltp-point-selects=N          number of point selects [10] 
  --oltp-simple-ranges=N          number of simple ranges [1] 
  --oltp-sum-ranges=N            number of sum ranges [1] 
  --oltp-order-ranges=N          number of ordered ranges [1] 
  --oltp-distinct-ranges=N        number of distinct ranges [1] 
  --oltp-index-updates=N          number of index update [1] 
  --oltp-non-index-updates=N      number of non-index updates [1] 
  --oltp-nontrx-mode=STRING      mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select] 
  --oltp-auto-inc=[on|off]        whether AUTO_INCREMENT (or equivalent) should be used on id column [on] 
  --oltp-connect-delay=N          time in microseconds to sleep after connection to database [10000] 
  --oltp-user-delay-min=N        minimum time in microseconds to sleep after each request [0] 
  --oltp-user-delay-max=N        maximum time in microseconds to sleep after each request [0] 
  --oltp-table-name=STRING        name of test table [sbtest] 
  --oltp-table-size=N            number of records in test table [10000] 
  --oltp-dist-type=STRING        random numbers distribution {uniform,gaussian,special} [special] 
  --oltp-dist-iter=N              number of iterations used for numbers generation [12] 
  --oltp-dist-pct=N              percentage of values to be treated as 'special' (for special distribution) [1] 
  --oltp-dist-res=N              percentage of 'special' values to use (for special distribution) [75] 
 
General database options: 
 
  --db-driver=STRING  specifies database driver to use ('help' to get list of available drivers) 
  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] 
 
 
Compiled-in database drivers: 
  mysql - MySQL driver 
 
mysql options: 
  --mysql-host=[LIST,...]      MySQL server host [localhost] 
  --mysql-port=N                MySQL server port [3306] 
  --mysql-socket=STRING        MySQL socket 
  --mysql-user=STRING          MySQL user [sbtest] 
  --mysql-password=STRING      MySQL password [] 
  --mysql-db=STRING            MySQL database name [sbtest] 
  --mysql-table-engine=STRING  storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb] 
  --mysql-engine-trx=STRING    whether storage engine used is transactional or not {yes,no,auto} [auto] 
  --mysql-ssl=[on|off]          use SSL connections, if available in the client library [off] 
  --myisam-max-rows=N          max-rows parameter for MyISAM tables [1000000] 
  --mysql-create-options=STRING additional options passed to CREATE TABLE [] 

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
MySQL的許可與其他數據庫系統相比如何?MySQL的許可與其他數據庫系統相比如何?Apr 25, 2025 am 12:26 AM

MySQL使用的是GPL許可證。 1)GPL許可證允許自由使用、修改和分發MySQL,但修改後的分發需遵循GPL。 2)商業許可證可避免公開修改,適合需要保密的商業應用。

您什麼時候選擇InnoDB而不是Myisam,反之亦然?您什麼時候選擇InnoDB而不是Myisam,反之亦然?Apr 25, 2025 am 12:22 AM

選擇InnoDB而不是MyISAM的情況包括:1)需要事務支持,2)高並發環境,3)需要高數據一致性;反之,選擇MyISAM的情況包括:1)主要是讀操作,2)不需要事務支持。 InnoDB適合需要高數據一致性和事務處理的應用,如電商平台,而MyISAM適合讀密集型且無需事務的應用,如博客系統。

在MySQL中解釋外鍵的目的。在MySQL中解釋外鍵的目的。Apr 25, 2025 am 12:17 AM

在MySQL中,外鍵的作用是建立表與表之間的關係,確保數據的一致性和完整性。外鍵通過引用完整性檢查和級聯操作維護數據的有效性,使用時需注意性能優化和避免常見錯誤。

MySQL中有哪些不同類型的索引?MySQL中有哪些不同類型的索引?Apr 25, 2025 am 12:12 AM

MySQL中有四種主要的索引類型:B-Tree索引、哈希索引、全文索引和空間索引。 1.B-Tree索引適用於範圍查詢、排序和分組,適合在employees表的name列上創建。 2.哈希索引適用於等值查詢,適合在MEMORY存儲引擎的hash_table表的id列上創建。 3.全文索引用於文本搜索,適合在articles表的content列上創建。 4.空間索引用於地理空間查詢,適合在locations表的geom列上創建。

您如何在MySQL中創建索引?您如何在MySQL中創建索引?Apr 25, 2025 am 12:06 AM

toCreateAnIndexinMysql,usethecReateIndexStatement.1)forasingLecolumn,使用“ createIndexIdx_lastNameEnemployees(lastName); 2)foracompositeIndex,使用“ createIndexIndexIndexIndexIndexDx_nameOmplayees(lastName,firstName,firstName);” 3)forauniqe instex,creationexexexexex,

MySQL與Sqlite有何不同?MySQL與Sqlite有何不同?Apr 24, 2025 am 12:12 AM

MySQL和SQLite的主要區別在於設計理念和使用場景:1.MySQL適用於大型應用和企業級解決方案,支持高性能和高並發;2.SQLite適合移動應用和桌面軟件,輕量級且易於嵌入。

MySQL中的索引是什麼?它們如何提高性能?MySQL中的索引是什麼?它們如何提高性能?Apr 24, 2025 am 12:09 AM

MySQL中的索引是數據庫表中一列或多列的有序結構,用於加速數據檢索。 1)索引通過減少掃描數據量提升查詢速度。 2)B-Tree索引利用平衡樹結構,適合範圍查詢和排序。 3)創建索引使用CREATEINDEX語句,如CREATEINDEXidx_customer_idONorders(customer_id)。 4)複合索引可優化多列查詢,如CREATEINDEXidx_customer_orderONorders(customer_id,order_date)。 5)使用EXPLAIN分析查詢計劃,避

說明如何使用MySQL中的交易來確保數據一致性。說明如何使用MySQL中的交易來確保數據一致性。Apr 24, 2025 am 12:09 AM

在MySQL中使用事務可以確保數據一致性。 1)通過STARTTRANSACTION開始事務,執行SQL操作後用COMMIT提交或ROLLBACK回滾。 2)使用SAVEPOINT可以設置保存點,允許部分回滾。 3)性能優化建議包括縮短事務時間、避免大規模查詢和合理使用隔離級別。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境