zoukankan      html  css  js  c++  java
  • [转]如何监控MySQL性能?

    一,获取mysql用户下的进程总数

    ps -ef | awk '{print $1}' | grep "mysql" | grep -v "grep" | wc-1

    二,主机性能状态

    # uptime

    [root@ ~]# uptime
     13:05:52 up 53 days, 52 min,  1 user,  load average: 0.00, 0.00, 0.00

    三,CPU使用率

    # top

    # vmstat

    四,磁盘IO量

    # vmstat 或 # iostat
    五,swap进出量[内存]

    # free
    六,数据库性能状态
    (1)QPS(每秒Query量)
    QPS = Questions(or Queries) / seconds
    mysql > show /*50000 global */ status like 'Question';

    (2)TPS(每秒事务量)
    TPS = (Com_commit + Com_rollback) / seconds
    mysql > show status like 'Com_commit';
    mysql > show status like 'Com_rollback';

    (3)key Buffer 命中率
    key_buffer_read_hits = (1-key_reads / key_read_requests) * 100%
    key_buffer_write_hits = (1-key_writes / key_write_requests) * 100%

    mysql> show status like 'Key%';

    (4)InnoDB Buffer命中率
    innodb_buffer_read_hits = (1 - innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%

    mysql> show status like 'innodb_buffer_pool_read%';

    (5)Query Cache命中率
    Query_cache_hits = (Qcahce_hits / (Qcache_hits + Qcache_inserts )) * 100%;

    mysql> show status like 'Qcache%';
    (6)Table Cache状态量
    mysql> show status like 'open%';

    (7)Thread Cache 命中率
    Thread_cache_hits = (1 - Threads_created / connections ) * 100%

    mysql> show status like 'Thread%';

    mysql> show status like 'Connections';

    (8)锁定状态
    mysql> show status like '%lock%';

    (9)复制延时量
    mysql > show slave status

    (10) Tmp Table 状况(临时表状况)
    mysql > show status like 'Create_tmp%';
    (11) Binlog Cache 使用状况
    mysql > show status like 'Binlog_cache%';

    (12) Innodb_log_waits 量
    mysql > show status like 'innodb_log_waits';

    开源监控软件
    一,RRDTool
    二,Nagios
    三,MRTG
    四,Cacti

  • 相关阅读:
    mysql数据库安装,启动和关闭
    python学习笔记(xlsxwriter模块使用)
    redis集群搭建
    gpasswd 命令详解
    linux CPU使用率过高或负载过高的处理思路
    Django模型(ORM)
    Django模板层(template)
    Windows下安装node.js(npm) git+vue
    Sublime Text 3:3114的安装(目前最新),插件emmet的安装
    opacity在IE6~8下无效果,解决的办法
  • 原文地址:https://www.cnblogs.com/junhwong/p/3593952.html
Copyright © 2011-2022 走看看