mysqlslap --defaults-file=/etc/my.cnf --concurrency=100,200 --iterations=1 --number-int-cols=20 --number-char-cols=30 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --number-of-queries=2000 -uroot -pabc123 --verbose#模擬測試兩次讀寫并發(fā),第一次100,第二次200,自動生成SQL腳本,測試表包含20個init字段,30個char字段,每次執(zhí)行2000查詢請求。測試引擎分別是myisam,innodb。–defaults-file=/etc/my.cnf 從/etc/my.cnf文件中讀取默認選項
–concurrency=100,200 測試并發(fā)的線程數(shù)/客戶端數(shù),第一次100,第二次200
–iterations=1 指定測試重復(fù)次數(shù)1次
–number-int-cols=20 指定測試表中int列的數(shù)量
–number-char-cols=30 指定測試表中varchar列的數(shù)量
–auto-generate-sql 自動生成 SQL 語句
–auto-generate-sql-add-autoincrement 在自動生成的表中添加自增列
–auto-generate-sql-load-type=mixed 測試的負載模型,包括 mixed, update, write, key,read,默認是 mix
–engine=myisam,innodb 指定建表時的存儲引擎
–number-of-queries=2000 指定每個線程執(zhí)行的 SQL 語句數(shù)量上限(不精確)
–verbose 更詳細的輸出
Average number of seconds to run all queries #運行所有查詢的平均秒數(shù)Minimum number of seconds to run all queries #運行所有查詢所需的最小秒數(shù)Maximum number of seconds to run all queries #運行所有查詢的最大秒數(shù)Number of clients running queries #運行查詢的客戶端數(shù)量Average number of queries per client #每個客戶端的平均查詢數(shù)
mysqlslap --defaults-file=/etc/my.cnf --concurrency=200,400 --iterations=1 --number-int-cols=50 --number-char-cols=60 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --number-of-queries=80000 -uroot -pabc123 --verbose壓力調(diào)大測試,發(fā)現(xiàn)明顯現(xiàn)在查詢時間明顯變慢了
有關(guān) sysbench 本身提供的常規(guī)選項的說明,請參閱常規(guī)命令行選項。
#可用于顯示常規(guī)命令行語法和選項。sysbench --help
sysbench --help
Usage:sysbench [options]... [testname][command]Commands implemented by most tests: prepare run cleanup helpGeneral options: #普通功能--threads=N 要使用的線程數(shù),默認 1 個 [1]--events=N 最大允許的事件個數(shù) [0]--time=N 最大的總執(zhí)行時間,以秒為單位 [10]--forced-shutdown=STRING 在 --time 時間限制到達后,強制關(guān)閉之前等待的秒數(shù),默認“off”禁用--thread-stack-size=SIZE 每個線程的堆棧大小 [64K]--rate=N 平均傳輸速率。0 則無限制 [0]--report-interval=N 以秒為單位定期報告具有指定間隔的中間統(tǒng)計信息 0 禁用中間報告 [0]--report-checkpoints=[LIST,...] 轉(zhuǎn)儲完整的統(tǒng)計信息并在指定的時間點重置所有計數(shù)器。參數(shù)是一個逗號分隔的值列表,表示從測試開始經(jīng)過這個時間量時必須執(zhí)行報告檢查點(以秒為單位)。報告檢查點默認關(guān)閉。 []--debug[=on|off] 打印更多 debug 信息 [off]--validate[=on|off] 盡可能執(zhí)行驗證檢查 [off]--help[=on|off] 顯示幫助信息并退出 [off]--version[=on|off] 顯示版本信息并退出 [off]--config-file=FILENAME 包含命令行選項的文件--tx-rate=N 已棄用——rate [0]的別名--max-requests=N 已棄用 --events [0]的別名--max-time=N 已棄用 --time [0]的別名--num-threads=N 已棄用 --threads [1]的別名Pseudo-Random Numbers Generator options: #偽隨機數(shù)生成器選項--rand-type=STRING 隨機數(shù)分布 {uniform,gaussian,special,pareto} 默認使用[special]--rand-spec-iter=N 生成數(shù)字的迭代次數(shù)[12]--rand-spec-pct=N 被視為“特殊”(用于特殊分布)的值的百分比[1]--rand-spec-res=N 使用的“特殊”值的百分比(用于特殊分布)[75]--rand-seed=N 隨機數(shù)生成器的種子。0時,當(dāng)前時間作為RNG的種子。[0]--rand-pareto-h=N pareto分布的參數(shù)h [0.2]Log options: #日志選項--verbosity=N verbosity level {5 - debug, 0 - only critical messages}[3]--percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]--histogram[=on|off] print latency histogram in report [off]General database options:--db-driver=STRING specifies database driver to use ('help' to get list of available drivers)[mysql]--db-ps-mode=STRING prepared statements usage mode {auto, disable}[auto]--db-debug[=on|off] print database-specific debug information [off]Compiled-in database drivers:mysql - MySQL driverpgsql - PostgreSQL drivermysql options:--mysql-host=[LIST,...] MySQL server host[localhost]--mysql-port=[LIST,...] MySQL server port [3306]--mysql-socket=[LIST,...] MySQL socket--mysql-user=STRING MySQL user [sbtest]--mysql-password=STRING MySQL password []--mysql-db=STRING MySQL database name [sbtest]--mysql-ssl[=on|off] use SSL connections, if available in the client library [off]--mysql-ssl-cipher=STRING use specific cipher for SSL connections []--mysql-compression[=on|off] use compression, if available in the client library [off]--mysql-debug[=on|off] trace all client library calls [off]--mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all"[1213,1020,1205]--mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off]pgsql options:--pgsql-host=STRING PostgreSQL server host[localhost]--pgsql-port=N PostgreSQL server port [5432]--pgsql-user=STRING PostgreSQL user [sbtest]--pgsql-password=STRING PostgreSQL password []--pgsql-db=STRING PostgreSQL database name [sbtest]Compiled-in tests:fileio - File I/O testcpu - CPU performance testmemory - Memory functions speed testthreads - Threads subsystem performance testmutex - Mutex performance testSee 'sysbench <testname> help'for a list of options for each test.
mysql options:
–mysql-host=[LIST,…] MySQL server host[localhost]#MySQL服務(wù)器主機
–mysql-port=[LIST,…] MySQL server port [3306]#MySQL服務(wù)器端口
–mysql-socket=[LIST,…] MySQL socket #MySQL的套接字
–mysql-user=STRING MySQL user [sbtest]#MySQL用戶
–mysql-password=STRING MySQL password []#MySQL密碼
–mysql-db=STRING MySQL database name [sbtest]#MySQL數(shù)據(jù)庫名稱
–mysql-ssl[=on|off] use SSL connections, if available in the client library [off]#是否開啟ssl連接
–mysql-ssl-cipher=STRING use specific cipher for SSL connections []#對SSL連接使用特定的密碼
–mysql-compression[=on|off] use compression, if available in the client library [off]#是否開啟壓縮功能
–mysql-debug[=on|off] trace all client library calls [off]#是否跟蹤所有客戶端庫調(diào)用
–mysql-ignore-errors=[LIST,…] list of errors to ignore, or “all” [1213,1020,1205]#要忽略或“全部”的錯誤列表 --mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off] #模擬運行,假設(shè)所有的MySQL客戶端API調(diào)用都是成功的,但沒有執(zhí)行它們