zoukankan      html  css  js  c++  java
  • MYSQL常用的性能指标

    (1) QPS(每秒Query量)

    QPS = Questions(or Queries) / seconds

    mysql > show  global status like 'Question%';

    (2) TPS(每秒事务量)

    TPS = (Com_commit + Com_rollback) / seconds

    mysql > show global status like'Com_commit';

    mysql > show global status like'Com_rollback';

    (3)key Buffer 命中率

    mysql>show  global  status  like   'key%';

    key_buffer_read_hits = (1-key_reads /key_read_requests) * 100%

    key_buffer_write_hits = (1-key_writes /key_write_requests) * 100%

    (4)InnoDB Buffer命中率

    mysql> show status like'innodb_buffer_pool_read%';

    innodb_buffer_read_hits = (1 -innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%

    (5)Query Cache命中率

    mysql> show status like 'Qcache%';

    Query_cache_hits = (Qcahce_hits /(Qcache_hits + Qcache_inserts )) * 100%;

    (6)Table Cache状态量

    mysql> show global  status like 'open%';

    比较 open_tables  与opend_tables 值

    (7)Thread Cache 命中率

    mysql> show global status like'Thread%';

    mysql> show global status like'Connections';

    Thread_cache_hits = (1 - Threads_created /connections ) * 100%

    (8)锁定状态

    mysql> show global  status like '%lock%';

    Table_locks_waited/Table_locks_immediate=0.3%  如果这个比值比较大的话,说明表锁造成的阻塞比较严重

    Innodb_row_lock_waits innodb行锁,太大可能是间隙锁造成的

    (9)复制延时量

    mysql > show slave status

    查看延时时间

    (10) Tmp Table 状况(临时表状况)

    mysql > show status like 'Create_tmp%';

    Created_tmp_disk_tables/Created_tmp_tables比值最好不要超过10%,如果Created_tmp_tables值比较大,

    可能是排序句子过多或者是连接句子不够优化

    (11) Binlog Cache 使用状况

    mysql > show status like'Binlog_cache%';

    如果Binlog_cache_disk_use值不为0 ,可能需要调大 binlog_cache_size大小

    (12) Innodb_log_waits 量

    mysql > show status like'innodb_log_waits';

    Innodb_log_waits值不等于0的话,表明 innodblog  buffer 因为空间不足而等待

    (13)open file and table

    mysql> mysql -e "show global statuslike 'Open_files';

    mysql> mysql -e "show global statuslike 'Open_tables';

    (14) 慢查询

    开启慢查询:

             编辑/etc/my.cnf,在[mysqld]域中添加:

             slow_query_log= 1   # 开启慢查询

             slow_query_log_file=/data/mysql/slow.log   # 慢查询日志路径

             long_query_time= 1        # 慢查询的时长

    查看慢查询数量:

             执行mysqladminstatus

    (15)全日志

    查看全日志:

      show global variables like 'general_log';

    开启全日志:

        set global general_log=on;

    注意开启全日志会消耗服务器性能,一般只有在排查问题时才会短暂打开。

    ########### 分割线 ###########

    我们需要根据自己的情况进行配置优化,好的做法是MySQL服务器稳定运行了一段时间后,根据服务器的”状态”再进行优化。

  • 相关阅读:
    时间处理得到UTC时间
    java数据同步陷阱
    360公司2016笔试题
    YTU 1439: 2.4.5 Fractions to Decimals 分数化小数
    YTU 2422: C语言习题 n个数逆序
    YTU 2421: C语言习题 矩形法求定积分
    YTU 2427: C语言习题 整数排序
    YTU 2832: 使用指针访问数组元素--程序填空
    YTU 1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换
    HDU 1069:Monkey and Banana
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5827793.html
Copyright © 2011-2022 走看看