[root@t-filter1 liuhuang]# free -m total used free shared buffers cached Mem: 7870 2567 5302 0 584 1083 -/+ buffers/cache: 898 6971 Swap: 2047 1262 785 [root@t-filter1 liuhuang]#
MySQL5.7的庫performance_schema新增了幾張視圖,能夠用於各個維度查看內存的使用狀況,還有就是這個幾個視圖的信息還能夠在sys這個庫中查看:node
root@mysqldb 11:18: [performance_schema]> show tables like 'memory%'; +-----------------------------------------+ | Tables_in_performance_schema (memory%) | +-----------------------------------------+ | memory_summary_by_account_by_event_name | | memory_summary_by_host_by_event_name | | memory_summary_by_thread_by_event_name | | memory_summary_by_user_by_event_name | | memory_summary_global_by_event_name | +-----------------------------------------+ 5 rows in set (0.00 sec) root@mysqldb 14:45: [performance_schema]>
從表的名字大體就能夠看出,就是根據主機,進程,用戶,全局等維度對內存進行監控。同時sys也針對這些表的格式作了進一步的優化,使得咱們能夠很方便的查看。mysql
須要注意的一點就是部份內存維度的監控默認是關閉的,並非全部的內存監控維度是開啓的,還須要本身手動開啓這些監控信息:linux
root@mysqldb 14:51: [performance_schema]> update setup_instruments set enabled='yes' where name like 'memory%';
還有就是這些監控的信息只是會從當前使用的狀況開始進行監控的,以前的內存使用狀況是沒法獲取獲得的。git
root@mysqldb 14:57: [performance_schema]> select event_name,SUM_NUMBER_OF_BYTES_ALLOC from memory_summary_global_by_event_name order by SUM_NUMBER_OF_BYTES_ALLOC desc LIMIT 10; +------------------------------------------------------------------------------+---------------------------+ | event_name | SUM_NUMBER_OF_BYTES_ALLOC | +------------------------------------------------------------------------------+---------------------------+ | memory/performance_schema/events_statements_history_long | 14320000 | | memory/performance_schema/events_statements_summary_by_digest.tokens | 10240000 | | memory/performance_schema/events_statements_history_long.tokens | 10240000 | | memory/performance_schema/events_statements_history_long.sqltext | 10240000 | | memory/performance_schema/table_handles | 9502720 | | memory/performance_schema/events_statements_summary_by_thread_by_event_name | 9091072 | | memory/performance_schema/memory_summary_by_thread_by_event_name | 5898240 | | memory/performance_schema/events_statements_summary_by_digest | 5120000 | | memory/performance_schema/events_statements_summary_by_host_by_event_name | 4545536 | | memory/performance_schema/events_statements_summary_by_account_by_event_name | 4545536 | +------------------------------------------------------------------------------+---------------------------+ 10 rows in set (0.01 sec)
root@mysqldb 14:58: [performance_schema]> select event_name, SUM_NUMBER_OF_BYTES_ALLOC from memory_summary_by_thread_by_event_name order by SUM_NUMBER_OF_BYTES_ALLOC desc limit 20; +----------------------------------------------+---------------------------+ | event_name | SUM_NUMBER_OF_BYTES_ALLOC | +----------------------------------------------+---------------------------+ | memory/sql/Relay_log_info::mts_coor | 0 | | memory/sql/QUICK_RANGE_SELECT::alloc | 0 | | memory/sql/table_mapping::m_mem_root | 0 | | memory/sql/sp_head::call_mem_root | 0 | | memory/sql/sp_head::execute_mem_root | 0 | | memory/sql/sp_head::main_mem_root | 0 | | memory/sql/THD::sp_cache | 0 | | memory/sql/Warning_info::m_warn_root | 0 | | memory/sql/Protocol_local::m_rset_root | 0 | | memory/sql/Prepared_statement::main_mem_root | 0 | | memory/sql/Prepared_statement_map | 0 | | memory/sql/servers | 0 | | memory/sql/Table_triggers_list | 0 | | memory/sql/gdl | 0 | | memory/sql/new_frm_mem | 0 | | memory/sql/help | 0 | | memory/sql/thd::main_mem_root | 0 | | memory/sql/Delegate::memroot | 0 | | memory/sql/THD::transactions::mem_root | 0 | | memory/sql/display_table_locks | 0 | +----------------------------------------------+---------------------------+ 20 rows in set (0.01 sec)
這個時候咱們能夠根據這些進程名去google或者其餘的搜索引擎去獲取獲得這些相關的信息,這個時候就能夠比較很明確的根據具體的狀況在進行優化和調整。github
[root@TiDB-node2 ~]# numactl --show policy: default preferred node: current physcpubind: 0 1 2 3 4 5 6 7 cpubind: 0 nodebind: 0 membind: 0 [root@TiDB-node2 ~]# [root@TiDB-node2 ~]# numactl --hardware available: 1 nodes (0) node 0 cpus: 0 1 2 3 4 5 6 7 node 0 size: 8191 MB node 0 free: 4093 MB node distances: node 0 0: 10 [root@TiDB-node2 ~]#
同時開啓P_S和thread pool會致使內存泄露(percona 5.7.17版本)sql
The MySQL server is running with the --super-read-only option so it cannot execute this statement
要完全解決這個問題,務必須要升級到MySQL5.7.19版本。緩存