zoukankan      html  css  js  c++  java
  • Xmind-4.5.2 information_schema.tables视图项目

    4.5.3 视图项目一

    1. information_schema.tables应用案例-1
    背景: 历史遗留问题,几十张表是MyISAM引擎.
    问题: 业务稍微忙一些的时候,导致业务网站卡住.断电情况下,会有部分数据(索引)损坏.主从1年多没同步了.
    分析问题: 
        a. 确认版本5.5版本
        select version();
        b. 确认业务表的引擎
        select table_schema,table_name,engine from information_schema.tables
        where table_schema not in ('mysql','information_schema');
        # 查询业务库下的非InnoDB的表
        select table_schema,table_name,engine from information_schema.tables
        where table_schema not in ('mysql','information_schema') and engine !='innodb';
        # 确认是否是从低版本升级过来.
        
        c. 监控锁的情况
        show status like '%lock%'
        发现有很多table_lock信息. 
        
        d. 检查主从状态
        show slave status G
    处理方案: 
        a. 将所有非InnoDB表,查出来.
        select table_schema,table_name,engine from information_schema.tables
        where table_schema not in ('mysql','information_schema') and engine !='innodb';
        
        mysql> select table_schema,table_name,engine from information_schema.tables where table_schema not in ('mysql','information_schema','performance_schema','sys') and engine !='innodb';
        b. 将所有非InnoDB表,替换成InnoDB
        
    SELECT CONCAT("ALTER TABLE ",table_schema,".",table_name," ENGINE=INNODB;")
    FROM information_schema.tables 
    WHERE table_schema 
    NOT IN ('mysql','information_schema','performance_schema','sys') 
    AND ENGINE !='innodb'
    INTO OUTFILE '/tmp/alter.sql';
    

    视图项目二

    information_schema.processlist 应用案例-2
    zabbix 普鲁米修斯等添加监控项
    a. 监控业务用户登录的次数
    mysql> select user,count(*) from information_schema.processlist where user not in ('root','event_scheduler') gropup by user;
    b. 监控sleep的连接个数 
    mysql> select  COMMAND,count(*) from information_schema.processlist where  COMMAND='sleep';
    c. 监控业务用户的登录总时长 
    mysql>  select user,sum(TIME) from information_schema.processlist where user not in ('root','event_scheduler') group  by user;
    d. 监控业务用户的登录平均时长 
    mysql>  select user,AVG(TIME) from information_schema.processlist where user not in ('root','event_scheduler') group  by user;
    
  • 相关阅读:
    CF799B T-shirt buying
    luogu3469 [POI2008]BLO_Blockade
    luogu2746 校园网
    USACO 2.2 Party Lamps 【高能等效+规律枚举】
    USACO 2.2 Subset Sums 【经典的方案DP+必要的转化】
    USACO 2.2 Preface Numbering 【实质是分治思想】
    bzoj 1051: [HAOI2006]受欢迎的牛 (Tarjan 缩点)
    bzoj 1088: [SCOI2005]扫雷Mine
    bzoj 2761: [JLOI2011]不重复数字 (map||Treap)
    bzoj 1230: [Usaco2008 Nov]lites 开关灯
  • 原文地址:https://www.cnblogs.com/hypj/p/14164838.html
Copyright © 2011-2022 走看看