本文共 6911 字,大约阅读时间需要 23 分钟。
[root@t-filter1 liuhuang]# free -m total used free shared buffers cachedMem: 7870 2567 5302 0 584 1083-/+ buffers/cache: 898 6971Swap: 2047 1262 785[root@t-filter1 liuhuang]#
MySQL5.7的库performance_schema新增了几张视图,可以用于各个维度查看内存的使用情况,还有就是这个几个视图的信息还可以在sys这个库中查看:
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也针对这些表的格式做了进一步的优化,使得我们可以很方便的查看。
需要注意的一点就是部分内存维度的监控默认是关闭的,并不是所有的内存监控维度是开启的,还需要自己手动开启这些监控信息:
root@mysqldb 14:51: [performance_schema]> update setup_instruments set enabled='yes' where name like 'memory%';
还有就是这些监控的信息只是会从当前使用的情况开始进行监控的,之前的内存使用情况是无法获取得到的。
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或者其他的搜索引擎去获取得到这些相关的信息,这个时候就可以比较很明确的根据具体的情况在进行优化和调整。
[root@TiDB-node2 ~]# numactl --showpolicy: defaultpreferred node: currentphyscpubind: 0 1 2 3 4 5 6 7cpubind: 0nodebind: 0membind: 0[root@TiDB-node2 ~]#[root@TiDB-node2 ~]# numactl --hardwareavailable: 1 nodes (0)node 0 cpus: 0 1 2 3 4 5 6 7node 0 size: 8191 MBnode 0 free: 4093 MBnode distances:node 0 0: 10[root@TiDB-node2 ~]#
同时开启P_S和thread pool会导致内存泄露(percona 5.7.17版本)
The MySQL server is running with the --super-read-only option so it cannot execute this statement
要彻底解决这个问题,务必需要升级到MySQL5.7.19版本。
转载于:https://blog.51cto.com/11819159/2128099