table open cache efficiency = Table_open_cache_hits/(Table_open_cache_misses+ Table_open_cache_hits) select * from performance_schema.global_status where variable_name in ('Table_open_cache_hits','Table_open_cache_misses');
21.incoming netword traffic(Bytes/Second)(每秒從全部客戶端接收的字節數)mysql
incoming netword traffic(Bytes/Second)= Bytes_received/Uptime; select * from performance_schema.global_status where variable_name in ('Bytes_received','Uptime');
22.Outgoing Network Traffic(Kbytes/Second)(每秒發送給全部客戶端的千字節數)sql
Outgoing Network Traffic(Kbytes/Second)= Bytes_sent/Uptime/1024; select * from performance_schema.global_status where variable_name in ('Bytes_sent','Uptime');
23.transaction_isolation:實例的隔離級別。數據庫
show global variables like 'transaction_isolation';
一、查看此時有多少個鎖等待緩存
select count(*) from information_schema.INNODB_LOCKS;
二、innodb_row_lock_waits:數據庫運行以來一共發生了多少次行鎖等待安全
show global status where variable_name ='innodb_row_lock_waits';
三、Innodb_row_lock_current_waits: InnoDB表上當前等待的行鎖數。獲取方式:show global status服務器
四、Innodb_row_lock_time: 獲取innodb行鎖須要等待的時間,單位:毫秒。獲取方式:show global statussession
五、Innodb_row_lock_time_max:獲取InnoDB錶行鎖的最長時間,單位:毫秒。獲取方式:show global statusdom
一、Innodb_buffer_pool_wait_free: Innodb的IO線程從數據文件中讀取了數據要寫入buffer pool的時候,須要等待空閒頁的次數。若是該值太大,須要增長innodb_buffer_pool_size。獲取方式:show global statusfetch
二、Innodb_log_waits: 由於日誌緩衝(log buffer)不足致使等待的次數。該值若是太大,須要增大innodb_log_buffer_size的值。獲取方式:show global statusspa
三、Innodb buffer pool usege rete(innodb buffer pool使用率):業務高峯建議值不超過95%。
Innodb buffer pool usege rete=innodb_buffer_pool_pages_data/innodb_buffer_pool_pages_total x 100% ##能夠參考這個值以及結合其它狀態來判斷是否增長innodb_buffer_pool_size。 select * from performance_schema.global_status where variable_name in ('innodb_buffer_pool_pages_data','innodb_buffer_pool_pages_total');
四、Innodb Buffer pool hit rate(innodb buffer pool命中率)(建議值不低於98%。):
獲取方式一:
show engine innodb status,而後查看BUFFER POOL AND MEMORY節中的Buffer pool hit rate。
獲取方式二:
Innodb Buffer pool hit rate=Innodb_buffer_pool_read_requests/(Innodb_buffer_pool_read_requests+Innodb_buffer_pool_reads+Innodb_buffer_pool_read_ahead) select * from performance_schema.global_status where variable_name in ('Innodb_buffer_pool_read_requests','Innodb_buffer_pool_reads','Innodb_buffer_pool_read_ahead');
五、innodb_dblwr_pages_written/innodb_dblwr_writes:數據庫的寫入壓力。
Innodb_dblwr_pages_written表示double write一共寫了多少頁,Innodb_dblwr_writes表示double write實際寫入次數。若是innodb_dblwr_pages_written/innodb_dblwr_writes大於64說明寫入壓力很高。獲取方式:show global status。相對於醫院能夠考慮下降一半,大於32報警。
六、hash searches/s:每秒使用自適應哈希索引的次數。經過查看這個值來判斷是否禁用自適應哈希索引。獲取方式:show engine innodb status
一、查看當前innodb表建立的innodb臨時表(支持5.7和8.0)。
select count(*) from information_schema.INNODB_TEMP_TABLE_INFO;
二、查看自啓動以來innodb表的插入、刪除、更新、查詢的行數(須要打開計數器set global innodb_monitor_enable = all;)
SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME='dml_inserts'; SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME='dml_deletes'; SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME='dml_updates'; SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME='dml_reads';
select user,host from mysql.user where (Drop_priv='Y' OR Grant_priv='Y' OR Super_priv='Y' OR Alter_priv='Y' OR Shutdown_priv='Y' OR Lock_tables_priv='Y') and user not in ('mysql.session');
8.0:
SELECT USER,HOST FROM mysql.user where account_locked='Y' AND USER NOT IN ('mysql.session','mysql.sys','mysql.infoschema');
5.7:
SELECT USER,HOST FROM mysql.user where account_locked='Y' AND USER NOT IN ('mysql.session','mysql.sys');
5.6如下包括5.6,沒有鎖定用戶的功能。
select user,host from mysql.user where password_expired = 'Y';
上面的語句是找到建立時建立就指定了過時的語句,例以下面的語句。
CREATE USER 'jeffrey'@'%' IDENTIFIED by '123456a!' password expire;
一、確認系統是否設置了 default_password_lifetime 變量值。
show global variables like 'default_password_lifetime';
若是爲0,表示沒有啓用系統的密碼過時策略,則執行步驟2,就能拿到全部用戶的過時天數。若是不爲0,則步驟2和步驟3都要執行。
二、找出指定了密碼過時的用戶(這個優先級高於系統設置的變量)
SELECT USER,HOST,password_lifetime,password_last_changed,DATEDIFF(ADDDATE(password_last_changed,password_lifetime),CURDATE()) AS dr FROM mysql.user WHERE password_lifetime IS NOT NULL;
dr表示還有幾天到期,若是爲負數表示超過到期日期的天數。到期剩餘天數=最後一次修改密碼的時間+password_lifetime-CURDATE()
三、取出使用全局的密碼過時策略的用戶的到期時間
(因爲5.7要開啓show_compatibility_56參數,因此不能一步算出來,須要將default_password_lifetime的值收集到咱們的庫裏,而後在進行加減。)
SELECT USER,HOST,password_last_changed,CURDATE() FROM mysql.user WHERE password_lifetime IS NULL;
password_last_changed表示最後一次修改密碼的時間。到期剩餘天數=最後一次修改密碼的時間+default_password_lifetime-CURDATE()
一、validate_password_policy:設置密碼策略。須要安裝validate_password,不然下面的參數都不可用
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
值 |
進行的檢測 |
0 or LOW |
長度; |
1 or MEDIUM |
長度;數字、小寫/大寫和特殊字符 |
2 or STRONG |
長度;數字、小寫/大寫和特殊字符;字典文件 |
二、validate_password_number_count:當validate_password_policy爲MEDIUM或STRONG,則要求密碼最少具備多少個數字字符數。
三、validate_password_special_char_count:當validate_password_policy爲MEDIUM或STRONG,則要求密碼中最少具備多少個特殊字符數。
四、validate_password_mixed_case_count:當validate_password_policy爲MEDIUM或STRONG,則要求密碼中最少具備多少個小寫字符和大寫字符。
五、validate_password_length:須要密碼中最少具備多少個字符數。值的設置不能小於此表達式的值:
validate_password_number_count + validate_password_special_char_count + ( 2 * validate_password_mixed_case_count )
六、validate_password_dictionary_file:設置檢查密碼字典文件的路徑和文件名。當validate_password_policy爲STRONG,密碼長度大於4的每一個子串都將與字典文件中的單詞進行比較。任何匹配都會致使密碼被拒絕。比較不區分大小寫。(指定的密碼字典文件不須要設置屬主爲mysql。密碼字典表中的單詞須要知足大於4個字符串。)
show global variables like 'log_bin';
SELECT object_schema,object_name,count_read AS rows_full_scanned FROM performance_schema.table_io_waits_summary_by_index_usage WHERE index_name IS NULL AND count_read > 0 ORDER BY count_read DESC;
SELECT object_schema,object_name,index_name FROM performance_schema.table_io_waits_summary_by_index_usage WHERE index_name IS NOT NULL AND count_star = 0 AND object_schema not in ('mysql','performance_schema') AND index_name <> 'PRIMARY' ORDER BY object_schema, object_name;
SELECT object_schema AS table_schema,object_name AS table_name,count_star AS rows_io_total,count_read AS rows_read,count_write AS rows_write,count_fetch AS rows_fetchs,count_insert AS rows_inserts,count_update AS rows_updates,count_delete AS rows_deletes FROM performance_schema.table_io_waits_summary_by_table ORDER BY sum_timer_wait DESC limit 10;
select table_schema,table_name,redundant_index_name,redundant_index_columns,dominant_index_name,dominant_index_columns from sys.schema_redundant_indexes order by table_name;