年底了,給MySQL做個例行巡檢吧
前言:
例行巡檢是節假日來臨之前的必做項目,對服務器做一輪全面的健康檢查,一方面可以確保節假日期間服務器的穩定,另外還可以檢查一下平時監控沒覆蓋到的地方。
連《爐石傳說》這麼強大的運維團隊都能把數據弄丟,你還有什麼理由不做一次巡檢呢?
巡檢主要分如下4個層面:
1.硬件
2.操作系統
3.數據庫
4.架構
5.ETL
巡檢項目:
如需詳細大圖與備注請直接聯系我,站內不允許上傳mindmanger格式的文件。
巡檢腳本:
- #!/bin/bash
- #這個腳本的功能是對MySQL進行巡檢
- #Written by LiHui
- #Version 1.1
- #Data:2017-01-19
- echo -e "\033[33m========================= 硬件檢查 =========================\033[0m"
- echo -e "\033[31m=====顯示開機信息===== \033[0m"
- dmesg | tail -20
- echo -e "\033[31m=====查看RAID陣列信息===== \033[0m"
- /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL
- echo -e "\033[31m=====檢查物理磁盤SMART信息===== \033[0m"
- /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|egrep 'Slot|S.M.A.R.T'
- echo -e "\033[31m=====檢查RAID電池狀態===== \033[0m"
- /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -a0|grep -E 'Charger|isSOHGood|Cycle Count|Max Error'
- echo -e "\033[33m========================= 操作系統檢查 =========================\033[0m"
- echo -e "\033[31m=====啟動項檢查===== \033[0m"
- chkconfig --list |grep -E "lvs|iptables|zabbix_agentd"
- echo -e "\033[31m=====MySQL啟動項檢查===== \033[0m"
- cat /etc/rc.d/rc.local |grep mysql
- echo -e "\033[31m=====IO性能檢查===== \033[0m"
- vmstat 1 5
- echo -e "\033[31m=====內存檢查===== \033[0m"
- free -m
- echo -e "\033[31m=====操作系統日志檢查===== \033[0m"
- tail -50 /var/log/messages
- echo -e "\033[31m=====磁盤空間檢查===== \033[0m"
- df -h
- echo -e "\033[31m=====網絡情況檢查===== \033[0m"
- ifconfig|grep errors
- echo -e "\033[33m========================= 數據庫檢查 =========================\033[0m"
- 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
- 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
- echo -e "\033[33m========================= 架構檢查 =========================\033[0m"
- 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
- echo -e "\033[31m=====虛擬IP檢查===== \033[0m"
- ip addr|grep lo |grep -v eth1