mysql内存使用监控_MySQL -- 内存使用监控详解

第一步: 配置performance_schema使它开启内存方面的监控

在/etc/my.cnf中增加如下内容

引用

####  for performance_schema

performance_schema                                                      =on    #    on

performance_schema_consumer_events_stages_current                       =on    #    off

performance_schema_consumer_events_stages_history                       =on    #    off

performance_schema_consumer_events_stages_history_long                  =off   #    off

performance_schema_consumer_statements_digest                           =on    #    on

performance_schema_consumer_events_statements_current                   =on    #    on

performance_schema_consumer_events_statements_history                   =on    #    on

performance_schema_consumer_events_statements_history_long              =off   #    off

performance_schema_consumer_events_waits_current                        =on    #    off

performance_schema_consumer_events_waits_history                        =on    #    off

performance_schema_consumer_events_waits_history_long                   =off   #    off

performance_schema_consumer_global_instrumentation                      =on    #    on

performance_schema_consumer_thread_instrumentation                      =on    #    on

performance-schema-instrument                                           ='memory/%=COUNTED'

第二步:重启mysql数据库

引用

systemctl restart mysql

第三步:通过performance_schema查询内存的使用情况

引用

mysql> SELECT SUBSTRING_INDEX(event_name,'/',2) AS code_area, sys.format_bytes(SUM(current_alloc)) AS current_alloc

-> FROM sys.x$memory_global_by_current_bytes GROUP BY SUBSTRING_INDEX(event_name,'/',2) ORDER BY SUM(current_alloc) DESC;

+---------------------------+---------------+

| code_area                 | current_alloc |

+---------------------------+---------------+

| memory/innodb             | 1.47 GiB      |

| memory/performance_schema | 131.51 MiB    |

| memory/mysys              | 8.22 MiB      |

| memory/sql                | 3.19 MiB      |

| memory/memory             | 213.15 KiB    |

| memory/myisam             | 171.79 KiB    |

| memory/csv                | 512 bytes     |

| memory/blackhole          | 512 bytes     |

+---------------------------+---------------+

8 rows in set (0.00 sec)

https://www.cnblogs.com/JiangLe/p/8663032.html

https://github.com/Neeky/mysqltools/blob/master/deploy/ansible/mysql/template/5.7/my.cnf

https://akingde.iteye.com/blog/1856545

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2019-06-12 13:59

浏览 142

分类:数据库

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值