溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何看待mysql 5.7 sys數(shù)據(jù)庫表

發(fā)布時間:2021-11-03 15:07:53 來源:億速云 閱讀:107 作者:柒染 欄目:MySQL數(shù)據(jù)庫

如何看待mysql 5.7 sys數(shù)據(jù)庫表,針對這個問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

引子

       mysql自mysql 5.6引入了performance_schema數(shù)據(jù)庫,對于監(jiān)控及調(diào)優(yōu)數(shù)據(jù)庫提供了極大的便利。但是performance_schema數(shù)據(jù)庫中有些數(shù)據(jù)仍顯粗放,不易利用,需要數(shù)據(jù)庫同學(xué)們進(jìn)行再次聚合開發(fā)。mysql 5.7開始,增加內(nèi)置數(shù)據(jù)庫sys,對于performance_schema數(shù)據(jù)庫的相關(guān)表進(jìn)行二次開發(fā)及封裝。便于運(yùn)維小伙伴直接使用,極大提升了運(yùn)維的效率。

     sys數(shù)據(jù)庫由一系列的表構(gòu)成。下列羅列一些重要表,方便大家入門,好有個直觀感受。

sys數(shù)據(jù)庫表

  • host_summary表

-----

  顯示以主機(jī)名稱分組的 SQL語句的數(shù)量,文件IO的數(shù)量,即文件IO的延遲,當(dāng)前的連接會話數(shù)量,連接對應(yīng)數(shù)據(jù)庫用戶數(shù)量,所對應(yīng)的內(nèi)存分配數(shù)量

(注:由此可知每個主機(jī)的負(fù)載分布情況,可以通過基本縱向?qū)Ρ?,知道,每個主機(jī)節(jié)點的負(fù)載的變化趨勢)

-----

mysql> select * from host_summary;
+-----------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+----------------+------------------------+
| host      | statements | statement_latency | statement_avg_latency | table_scans | file_ios | file_io_latency | current_connections | total_connections | unique_users | current_memory | total_memory_allocated |
+-----------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+----------------+------------------------+
| localhost |      17264 | 7.35 s            | 425.55 us             |         386 |    14512 | 1.07 s          |                   5 |                33 |            2 | 0 bytes        | 0 bytes                |
| three57   |         10 | 1.00 m            | 6.00 s                |           0 |       12 | 326.38 us       |                   0 |                 1 |            1 | 0 bytes        | 0 bytes                |
| two57     |         10 | 1.00 m            | 6.00 s                |           0 |       12 | 44.42 us        |                   0 |                 1 |            1 | 0 bytes        | 0 bytes                |
+-----------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+----------------+------------------------+
3 rows in set (0.01 sec)
  • host_summary_by_file_io表

----------

基于主機(jī)名稱進(jìn)行分組,顯示每個主機(jī)名稱的IO數(shù)量及IO延遲

----------

mysql> select * from host_summary_by_file_io;
+------------+------+------------+
| host       | ios  | io_latency |
+------------+------+------------+
| background | 3333 | 1.14 s     |
| localhost  | 7256 | 536.72 ms  |
| three57    |   12 | 326.38 us  |
| two57      |   12 | 44.42 us   |
+------------+------+------------+
4 rows in set (0.01 sec)
  • host_summary_by_file_io_type表

----

某個主機(jī)下到底哪個子組件的IO產(chǎn)生最多,然后進(jìn)行具體性分析

----

mysql> select * from host_summary_by_file_io_type;
+------------+--------------------------------------+-------+---------------+-------------+
| host       | event_name                           | total | total_latency | max_latency |
+------------+--------------------------------------+-------+---------------+-------------+
| background | wait/io/file/innodb/innodb_log_file  |   323 | 738.16 ms     | 19.08 ms    |
| background | wait/io/file/innodb/innodb_data_file |  1423 | 380.97 ms     | 21.19 ms    |
| background | wait/io/file/sql/binlog_index        |    31 | 12.76 ms      | 11.59 ms    |
| background | wait/io/file/sql/binlog              |    31 | 6.52 ms       | 2.14 ms     |
| background | wait/io/file/sql/FRM                 |  1404 | 951.13 us     | 29.74 us    |
| background | wait/io/file/sql/casetest            |    15 | 399.98 us     | 340.60 us   |
| background | wait/io/file/myisam/kfile            |    41 | 93.75 us      | 33.20 us    |
| background | wait/io/file/sql/ERRMSG              |     5 | 59.83 us      | 25.11 us    |
| background | wait/io/file/myisam/dfile            |    53 | 53.63 us      | 4.03 us     |
| background | wait/io/file/mysys/cnf               |     5 | 18.89 us      | 6.34 us     |
| background | wait/io/file/sql/pid                 |     3 | 16.42 us      | 10.14 us    |
| background | wait/io/file/mysys/charset           |     3 | 13.50 us      | 6.53 us     |
| background | wait/io/file/sql/global_ddl_log      |     2 | 3.15 us       | 1.87 us     |
| localhost  | wait/io/file/innodb/innodb_log_file  |    74 | 182.02 ms     | 16.42 ms    |
| localhost  | wait/io/file/sql/binlog              |    95 | 180.14 ms     | 15.37 ms    |
| localhost  | wait/io/file/sql/file_parser         |   438 | 76.83 ms      | 7.99 ms     |
| localhost  | wait/io/file/innodb/innodb_data_file |    47 | 35.92 ms      | 8.78 ms     |
| localhost  | wait/io/file/sql/FRM                 |  2511 | 24.19 ms      | 10.98 ms    |
| localhost  | wait/io/file/csv/metadata            |     8 | 10.64 ms      | 6.13 ms     |
  • host_summary_by_statement_latency表

----

每個主機(jī)的 延遲,以及最大延遲,延遲的構(gòu)成子組件

----

mysql> select * from sys.host_summary_by_statement_latency;
+------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| host       | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans |
+------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| two57      |    10 | 1.00 m        | 1.00 m      | 0 ps         |         5 |             0 |             0 |          0 |
| three57    |    10 | 1.00 m        | 1.00 m      | 0 ps         |         5 |             0 |             0 |          0 |
| localhost  |  9455 | 3.73 s        | 2.07 s      | 100.57 ms    |      3521 |        179048 |            21 |        197 |
| background |     0 | 0 ps          | 0 ps        | 0 ps         |         0 |             0 |             0 |          0 |
+------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
4 rows in set (0.01 sec)
  • memory_by_thread_by_current_bytes表

----

各個線程的內(nèi)存分配的性能對比(注:各種MYSQL線程:IO READ THREAD,IO WRITE THREAD,

PAGE_CLEANER THREAD,IBUF THREAD,WORKER_THREAD,MONITOR THREAD,LOCK TIMEOUT

 THREAD,DUMP THREAD,用于組復(fù)制的 接受線程及用于組復(fù)制的認(rèn)證廣播線程),SLAVE的SQL線程,

MAIN THREAD

(注:這樣就了解哪個線程消耗的內(nèi)存最多,進(jìn)行縱向?qū)Ρ?,就知?線程的消耗歷史,以及是否出現(xiàn)性能問題

----

mysql> select * from sys.memory_by_thread_by_current_bytes;
+-----------+---------------------------------------+--------------------+-------------------+-------------------+-------------------+-----------------+
| thread_id | user                                  | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated |
+-----------+---------------------------------------+--------------------+-------------------+-------------------+-------------------+-----------------+
|         5 | innodb/io_read_thread                 |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         6 | innodb/io_write_thread                |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         7 | innodb/io_write_thread                |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         8 | innodb/io_write_thread                |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         9 | innodb/io_write_thread                |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        10 | innodb/page_cleaner_thread            |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        11 | innodb/io_read_thread                 |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        12 | innodb/io_log_thread                  |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        13 | innodb/io_ibuf_thread                 |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        15 | innodb/srv_master_thread              |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        16 | innodb/srv_purge_thread               |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        17 | innodb/srv_worker_thread              |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        18 | innodb/srv_worker_thread              |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        19 | innodb/srv_worker_thread              |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        20 | innodb/srv_monitor_thread             |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        21 | innodb/srv_error_monitor_thread       |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        22 | innodb/srv_lock_timeout_thread        |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        23 | innodb/dict_stats_thread              |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        24 | innodb/buf_dump_thread                |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        25 | sql/signal_handler                    |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        26 | sql/compress_gtid_table               |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        31 | group_rpl/THD_applier_module_receiver |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        32 | group_rpl/THD_certifier_broadcast     |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        33 | sql/slave_sql                         |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        66 | root@localhost                        |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        67 | root@localhost                        |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|        68 | root@localhost                        |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         1 | sql/main                              |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         2 | sql/thread_timer_notifier             |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         3 | innodb/io_read_thread                 |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
|         4 | innodb/io_read_thread                 |                  0 | 0 bytes           | 0 bytes           | 0 bytes           | 0 bytes         |
+-----------+---------------------------------------+--------------------+-------------------+-------------------+-------------------+-----------------+
31 rows in set (0.04 sec)

關(guān)于如何看待mysql 5.7 sys數(shù)據(jù)庫表問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識。

向AI問一下細(xì)節(jié)

免責(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)容。

AI