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#模擬測試兩次讀寫并發,第一次100,第二次200,自動生成SQL腳本,測試表包含20個init字段,30個char字段,每次執行2000查詢請求。測試引擎分別是myisam,innodb。–defaults-file=/etc/my.cnf 從/etc/my.cnf文件中讀取默認選項
–concurrency=100,200 測試并發的線程數/客戶端數,第一次100,第二次200
–iterations=1 指定測試重復次數1次
–number-int-cols=20 指定測試表中int列的數量
–number-char-cols=30 指定測試表中varchar列的數量
–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 指定每個線程執行的 SQL 語句數量上限(不精確)
–verbose 更詳細的輸出
Average number of seconds to run all queries #運行所有查詢的平均秒數Minimum number of seconds to run all queries #運行所有查詢所需的最小秒數Maximum number of seconds to run all queries #運行所有查詢的最大秒數Number of clients running queries #運行查詢的客戶端數量Average number of queries per client #每個客戶端的平均查詢數
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壓力調大測試,發現明顯現在查詢時間明顯變慢了
有關 sysbench 本身提供的常規選項的說明,請參閱常規命令行選項。
#可用于顯示常規命令行語法和選項。sysbench --help
sysbench --help
Usage:sysbench [options]... [testname][command]Commands implemented by most tests: prepare run cleanup helpGeneral options: #普通功能--threads=N 要使用的線程數,默認 1 個 [1]--events=N 最大允許的事件個數 [0]--time=N 最大的總執行時間,以秒為單位 [10]--forced-shutdown=STRING 在 --time 時間限制到達后,強制關閉之前等待的秒數,默認“off”禁用--thread-stack-size=SIZE 每個線程的堆棧大小 [64K]--rate=N 平均傳輸速率。0 則無限制 [0]--report-interval=N 以秒為單位定期報告具有指定間隔的中間統計信息 0 禁用中間報告 [0]--report-checkpoints=[LIST,...] 轉儲完整的統計信息并在指定的時間點重置所有計數器。參數是一個逗號分隔的值列表,表示從測試開始經過這個時間量時必須執行報告檢查點(以秒為單位)。報告檢查點默認關閉。 []--debug[=on|off] 打印更多 debug 信息 [off]--validate[=on|off] 盡可能執行驗證檢查 [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: #偽隨機數生成器選項--rand-type=STRING 隨機數分布 {uniform,gaussian,special,pareto} 默認使用[special]--rand-spec-iter=N 生成數字的迭代次數[12]--rand-spec-pct=N 被視為“特殊”(用于特殊分布)的值的百分比[1]--rand-spec-res=N 使用的“特殊”值的百分比(用于特殊分布)[75]--rand-seed=N 隨機數生成器的種子。0時,當前時間作為RNG的種子。[0]--rand-pareto-h=N pareto分布的參數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服務器主機
–mysql-port=[LIST,…] MySQL server port [3306]#MySQL服務器端口
–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數據庫名稱
–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]#是否跟蹤所有客戶端庫調用
–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] #模擬運行,假設所有的MySQL客戶端API調用都是成功的,但沒有執行它們