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;
    
  • 相关阅读:
    Oracle存储过程(Stored Procedure)使用自定义类实体参数
    RTF格式富文本图片文本导出到Excel
    将EXCEL表格文字图片信息转成RTF格式写入数据库BLOB字段
    C# 阿拉伯数字转换为中文数字/中文数字转换为阿拉伯数字
    JavaScript操作select下拉框
    JavaScript操作浏览器一直往下滚动
    Microsoft Office 2003 Web Components 自动计数/自动求和
    SQLite递归
    WPF获取验证码倒计时
    System.UnauthorizedAccessException: 对路径“***”的访问被拒绝。
  • 原文地址:https://www.cnblogs.com/hypj/p/14164838.html
Copyright © 2011-2022 走看看