前言:

例行巡检是节假日来临之前的必做项目,对服务器做一轮全面的健康检查,一方面可以确保节假日期间服务器的稳定,另外还可以检查一下平时监控没覆盖到的地方。
连《炉石传说》这么强大的运维团队都能把数据弄丢,你还有什么理由不做一次巡检呢?

巡检主要分如下4个层面:

1.硬件

2.操作系统

3.数据库

4.架构

5.ETL

巡检项目:

年底了,给MySQL做个例行巡检吧-LMLPHP
如需详细大图与备注请直接联系我,站内不允许上传mindmanger格式的文件。

巡检脚本:

点击(此处)折叠或打开

  1. #!/bin/bash
  2. #这个脚本的功能是对MySQL进行巡检
  3. #Written by LiHui
  4. #Version 1.1
  5. #Data:2017-01-19

  6. echo -e "\033[33m========================= 硬件检查 =========================\033[0m"

  7. echo -e "\033[31m=====显示开机信息===== \033[0m"
  8. dmesg | tail -20

  9. echo -e "\033[31m=====查看RAID阵列信息===== \033[0m"
  10. /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL

  11. echo -e "\033[31m=====检查物理磁盘SMART信息===== \033[0m"
  12. /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|egrep 'Slot|S.M.A.R.T'

  13. echo -e "\033[31m=====检查RAID电池状态===== \033[0m"
  14. /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -a0|grep -E 'Charger|isSOHGood|Cycle Count|Max Error'


  15.  
  16. echo -e "\033[33m========================= 操作系统检查 =========================\033[0m"

  17. echo -e "\033[31m=====启动项检查===== \033[0m"
  18. chkconfig --list |grep -E "lvs|iptables|zabbix_agentd"

  19. echo -e "\033[31m=====MySQL启动项检查===== \033[0m"
  20. cat /etc/rc.d/rc.local |grep mysql

  21. echo -e "\033[31m=====IO性能检查===== \033[0m"
  22. vmstat 1 5

  23. echo -e "\033[31m=====内存检查===== \033[0m"
  24. free -m

  25. echo -e "\033[31m=====操作系统日志检查===== \033[0m"
  26. tail -50 /var/log/messages

  27. echo -e "\033[31m=====磁盘空间检查===== \033[0m"
  28. df -h

  29. echo -e "\033[31m=====网络情况检查===== \033[0m"
  30. ifconfig|grep errors



  31. echo -e "\033[33m========================= 数据库检查 =========================\033[0m"

  32. for i in `netstat -nult |grep 33|awk -F ':' '{print $2}'|awk '{print $1}'`;do echo -e "\033[31m=====THIS SECTION IS BUFFER POOL FOR PORT " $i "===== \033[0m"; mysql -uxxx -pxxx -S /data0/mysqldata/$i/mysql.sock -e 'show engine innodb status \G' |grep 'Free buffers';done

  33. for i in `netstat -nult |grep 33|awk -F ':' '{print $2}'|awk '{print $1}'`; do echo -e "\033[31m=====THIS SECTION IS ERROR LOG FOR PORT " $i "===== \033[0m"; tail -50 /data0/mysqldata/$i/mysql-error.log; done



  1. echo -e "\033[33m========================= 架构检查 =========================\033[0m"

  2. for i in `netstat -nult |grep 33|awk -F ':' '{print $2}'|awk '{print $1}'`;do echo -e "\033[31m=====THIS SECTION IS SLAVE STATUS FOR PORT " $i "===== \033[0m"; mysql -uxxx -pxxx -S /data0/mysqldata/$i/mysql.sock -e 'show slave status \G' |grep -E 'Slave_IO_Running|Slave_SQL_Running|Master_Log_File|Read_Master_Log_Pos|Relay_Master_Log_File|Exec_Master_Log_Pos|Seconds_Behind_Master';done

  3. echo -e "\033[31m=====虚拟IP检查===== \033[0m"
  4. ip addr|grep lo |grep -v eth1



12-14 13:53