登錄mysql數據庫查看內存
mysql> select event_name,current_alloc from sys.memory_global_by_current_bytes limit 10;
+--------------------------------------------------------------------+---------------+
| event_name | current_alloc |
+--------------------------------------------------------------------+---------------+
| memory/innodb/buf_buf_pool | 4.09 GiB |
| memory/innodb/hash0hash | 114.91 MiB |
| memory/sql/TABLE_SHARE::mem_root | 114.68 MiB |
| memory/sql/TABLE | 75.82 MiB |
| memory/temptable/physical_ram | 73.00 MiB |
| memory/innodb/memory | 67.51 MiB |
| memory/innodb/ut0new | 64.08 MiB |
| memory/mysys/IO_CACHE | 60.98 MiB |
| memory/performance_schema/events_statements_summary_by_digest | 39.67 MiB |
| memory/performance_schema/events_errors_summary_by_thread_by_error | 36.27 MiB |
+--------------------------------------------------------------------+---------------+
10 rows in set (0.00 sec)mysql
mysql> sql
mysql> select host,current_allocated from sys.memory_by_host_by_current_bytes;
+---------------+-------------------+
| host | current_allocated |
+---------------+-------------------+
| xx.xx.xx.xx | 183.54 GiB |
| 127.0.0.1 | 16.29 GiB |
| localhost | 70.63 MiB |
| background | -183.39 GiB |
+---------------+-------------------+
10 rows in set (0.02 sec)數據庫
#free -m
total used free shared buff/cache available
Mem: 7783 5624 63 522 2095 1503
Swap: 16379 2 16377ide
我物理內存8G,你咋還查出來183.54GiB,只能說mysql在內存方面的監控很爛啊,但願之後有所改進,仍是經過操做系統命令top來看比較準一些。
以下圖:
看VIRT和RES便可,若是和你配置的數據庫buffer差很少,就不存在內存泄漏。咱們若是想看在某個時間點哪一個SQL佔用了多少內存這個目前還作不到啊 。內存不夠該擴容就擴容,就這麼簡單。操作系統