您好,登錄后才能下訂單哦!
mysqlslap是mysql自帶的工具,不需要單獨安裝:
-concurrency 代表并發(fā)數(shù)量,多個可以用逗號隔開,concurrency=10,50,100, 并發(fā)連接線程數(shù)分別是10、50、100個并發(fā)。
--engines 代表要測試的引擎,可以有多個,用分隔符隔開。
--iterations 代表要運(yùn)行這些測試多少次。
--auto-generate-sql 代表用系統(tǒng)自己生成的SQL腳本來測試。
--auto-generate-sql-load-type 代表要測試的是讀還是寫還是兩者混合的(read,write,update,mixed)
--number-of-queries 代表總共要運(yùn)行多少次查詢。每個客戶運(yùn)行的查詢數(shù)量可以用查詢總數(shù)/并發(fā)數(shù)來計算。
--debug-info 代表要額外輸出CPU以及內(nèi)存的相關(guān)信息。
--number-int-cols :創(chuàng)建測試表的 int 型字段數(shù)量
--auto-generate-sql-add-autoincrement : 代表對生成的表自動添加auto_increment列,從5.1.18版本開始
--number-char-cols 創(chuàng)建測試表的 char 型字段數(shù)量。
--create-schema 測試的schema,MySQL中schema也就是database。
--query 使用自定義腳本執(zhí)行測試,例如可以調(diào)用自定義的一個存儲過程或者sql語句來執(zhí)行測試。
--only-print 如果只想打印看看SQL語句是什么,可以用這個選項。
[root@Linux_Aolens_01 /home/aolens]# mysqlslap --user=root --password=password --auto-generate-sql Benchmark Average number of seconds to run all queries: 0.002 seconds Minimum number of seconds to run all queries: 0.002 seconds Maximum number of seconds to run all queries: 0.002 seconds Number of clients running queries: 1 Average number of queries per client: 0
結(jié)果中各項含義:
Average number of ... 運(yùn)行所有語句的平均秒數(shù)
Minimum number of ... 運(yùn)行所有語句的最小秒數(shù)
Maximum number of ... 運(yùn)行所有語句的最大秒數(shù)
Number of clients ... 客戶端數(shù)量
Average number of queries per client 每個客戶端運(yùn)行查詢的平均數(shù)
[root@Linux_Aolens_01 /home/aolens]# mysqlslap --user=root --password=password --auto-generate-sql --concurrency=100 --number-of-queries=1000 Benchmark Average number of seconds to run all queries: 0.316 seconds Minimum number of seconds to run all queries: 0.316 seconds Maximum number of seconds to run all queries: 0.316 seconds Number of clients running queries: 100 Average number of queries per client: 10
3,使用自己測試庫和測試語句
[root@Linux_Aolens_01 /home/aolens]# mysqlslap --user=root --password=password --concurrency=10 --number-of-queries=100 --create-schema=wordpress --query="SELECT * FROM wordpress.wp_posts;" Benchmark Average number of seconds to run all queries: 4.255 seconds Minimum number of seconds to run all queries: 4.255 seconds Maximum number of seconds to run all queries: 4.255 seconds Number of clients running queries: 10 Average number of queries per client: 10
數(shù)據(jù)庫Mariadb 10.0.14
首先給數(shù)據(jù)庫安裝審計插件,并啟用
MariaDB [(none)]> show variables like '%audit%' -> ; +-------------------------------+-----------------------+ | Variable_name | Value | +-------------------------------+-----------------------+ | server_audit_events | | | server_audit_excl_users | | | server_audit_file_path | server_audit.log | | server_audit_file_rotate_now | OFF | | server_audit_file_rotate_size | 1000000 | | server_audit_file_rotations | 9 | | server_audit_incl_users | | | server_audit_logging | OFF | | server_audit_mode | 0 | | server_audit_output_type | file | | server_audit_syslog_facility | LOG_USER | | server_audit_syslog_ident | mysql-server_auditing | | server_audit_syslog_info | | | server_audit_syslog_priority | LOG_INFO | +-------------------------------+-----------------------+ 14 rows in set (0.00 sec)
發(fā)現(xiàn)已經(jīng)安裝了,沒有安裝的MariaDB [(none)]> INSTALL PLUGIN server_audit SONAME 'server_audit.so';
命令行啟動審計功能:
命令行啟用audit ,重啟后失效
MariaDB [(none)]> set global server_audit_file_rotate_size=1024*1024*1024; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> set global server_audit_events='query,table'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> set global server_audit_file_rotate_now=on; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> set global server_audit_logging='ON'; Query OK, 0 rows affected (0.00 sec)
刷新一下首頁查看審計日志里都有哪些SQL操作,對這些SQL進(jìn)行壓測:
mysqlslap --user=root --password=password --concurrency=20 --number-of-queries=1000 --create-schema=wordpress --query=" \ SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'; \ SELECT option_value FROM wp_options WHERE option_name = 'a3_lz_google_api_key' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'a3_lz_google_api_key_enable' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = '_transient_timeout_a3_lz_google_api_key_status' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = '_transient_a3_lz_google_api_key_status' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'wordpress_api_key' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'onp_license_clipboard-p_w_picpaths' LIMIT 1; \ SELECT autoload FROM wp_options WHERE option_name = 'onp_license_clipboard-p_w_picpaths'; \ SELECT option_value FROM wp_options WHERE option_name = 'onp_version_check_clipboard-p_w_picpaths' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'ossdl_https' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'uninstall_plugins' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'a3_lazy_load_just_installed' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'akismet_comment_nonce' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'preload_cache_counter' LIMIT 1; \ SELECT option_value FROM wp_options WHERE option_name = 'rewrite_rules' LIMIT 1; \ ......" Benchmark Average number of seconds to run all queries: 40.931 seconds Minimum number of seconds to run all queries: 40.931 seconds Maximum number of seconds to run all queries: 40.931 seconds Number of clients running queries: 20 Average number of queries per client: 50
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。