zoukankan      html  css  js  c++  java
  • MySQL深度巡检

    1. IO层面检查

     
    (1)IO检查
     

    查看%util是否接近100%定位是哪个磁盘IO压力大

    #iostat -x 1 10
    (2)iotop定位负载来源进程
    查看哪个PID占用IO最高
    #iotop
    (3)pt-ioprofile定位负载来源文件
    查看哪个文件的IO占用时间最多
    #pt-ioprofile  --profile-pid=3712 --cell=sizes
     
     
    2.文件系统层面检查
    (1)查看当前系统的I/O调度
    假如MySQL数据文件存放在sda1里,不同的磁盘则选择不同的IO调度策略

    # cat /sys/block/sda/queue/scheduler

    (2)查看文件系统
    查看MySQL数据文件存放的文件系统是否为xfs或者ext4
    #mount
     
    3.linux内核参数检查

    # cat /etc/sysctl.cnf

     

    4.收集MySQL数据库基本信息

    (1)收集OS基本信息

    #pt-summary

    (2)查看MySQL统计信息

    #pt-mysql-summary --user=root --password=123456 --host=127.0.0.1 --port=3306

    (3)查看用户数据库的存储引擎

     mysql>select count(*) as cnt,table_schema,engine from information_schema.tables where table_schema not in('mysql','information_schema','PERFORMANCE_SCHEMA') group by table_schema,engine order by cnt desc;

    (4)查看所有表的存储引擎

     mysql>select table_schema,table_name,engine,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,INDEX_LENGTH from information_schema.tables where table_schema not in('mysql','information_schema','PERFORMANCE_SCHEMA') order by table_schema,TABLE_ROWS desc;

    (5)查看线程状态
    mysql> show full processlist;

    (6)如果第5步有不少SQL经常能看到,把那些SQL的执行计划也收集下,以及相应表的DDL
    mysql> explain select....
    mysql> show create table table_name;
    mysql> show index from table_name;

    (7)提供慢日志统计结果
    mysqldumpslow slow.log > slow-stat.log
    slow.log文件名改成你真正的慢日志文件名

    (8)查看死锁

    监控死锁

    #pt-deadlock-logger--ask-pass --run-time=10 --interval=3 --create-dest-table --dest D=test,t=deadlocks u=root,P=3306,h=127.0.0.1
    查看死锁
    mysql>select *  from deadlocksG;
    
    
    5.检查主从同步
    (1)从库检查同步状态
    检查Slave_IO_Running和Slave_SQL_Running是否都为YES
    mysql>show slave statusG;

    首先Master_Log_File和Relay_Master_Log_File所指向的文件必须一致。

    其次Relay_Log_Pos和Exec_Master_Log_Pos的为止也要一致才行。

    (2)主从数据校验

    mysql数据校验
    主库执行
    pt-table-checksum -uroot  --ask-pass --recursion-method=processlist --recurse=1  --no-check-binlog-format --nocheck-replication-filters --resume --max-lag=10
     
    从库:
    select * from percona.checksums where master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL(master_crc) <> ISNULL(this_crc);

    6.PXC集群检查

    (1)查看Galera集群每个节点状态

    mysql>show status like 'wsrep%';

    wsrep_cluster_status状态为Primary

    wsrep_connected为ON

    wsrep_cluster_state_uuid:在集群所有节点的值应该是相同的
    wsrep_local_state_comments是否为 Synced 表示节点处于工作状态
     
    (2)查看每个节点的4567端口
    #lsof -i :4567
    查看每个节点的4567端口和其他节点都是互通的
     
    7.MHA检查
    (1)检查启动的状态
    masterha_check_status --conf=/etc/masterha/app1.cnf
     
     

    (2)masterha_check_ssh验证ssh信任登录是否成功

    masterha_check_ssh --conf=/etc/masterha/app1.cnf

    (3)masterha_check_repl验证mysql复制是否成功  

    masterha_check_repl --conf=/etc/masterha/app1.cnf
     

    8.查看日志
    (1)查看报错日志

    mysql> show variables like 'log_error';

    #cat mysqlerr.log |grep -i -C 5 ERROR

    (2)查看备份日志 

  • 相关阅读:
    leetcode Super Ugly Number
    leetcode Find Median from Data Stream
    leetcode Remove Invalid Parentheses
    leetcode Range Sum Query
    leetcode Range Sum Query
    leetcode Minimum Height Trees
    hdu 3836 Equivalent Sets
    hdu 1269 迷宫城堡
    hud 2586 How far away ?
    poj 1330 Nearest Common Ancestors
  • 原文地址:https://www.cnblogs.com/wlmq/p/6113455.html
Copyright © 2011-2022 走看看