這篇文章介紹了檢查并修復mysql數據庫表的具體方法,有需要的朋友可以參考一下
#!/bin/sh #code?by?scpman #功能:檢查并修復mysql數據庫表 #將此腳本加到定時中,腳本執行時,等會讀庫,列出要修復的所有表,然后計時,開始修復 #修復過程中將損壞的表記錄下來,修復完成后,將損壞的表,發郵件通知。 fix_logs='/tmp/fix.log' user='' pass='' check_fix() { dblist=`/usr/bin/find?/usr/dlm_db/mysql/?-type?d?|?grep?-vE?"logs|_[1-9]|*bak|test"|?sed?-e?"s#/usr/dlm_db/mysql/##g"` echo?start?`date`>$fix_logs for?dbname?in?$dblist do echo?$dbname for?tb_name?in?`/usr/bin/find?/usr/dlm_db/mysql/$dbname?-type?f?|?awk?-F'/'?'{print?$NF}'?|?awk?-F'.'?'{print?$1}'?|?sort?- u` do mysql?-u$user?-p$pass?$dbname>$fix_logs check?table?$tb_name; repair?table?$tb_name; FFF done done echo?`date`?done>>$fix_logs } send_logs() { msgip=10.0.7.44 IP=`cat?/etc/rc.conf?|?grep?-E?"ifconfig_[em1|bce1]"?|?awk?'{print?"IP:"$2}'|?sed?-n?1p?` fix_info=`grep?-rE?"Error|start|done"?$fix_logs` /usr/bin/logger?-p?local1.info?-h?$msgip?"the?services:?$IP?mysql_table_fix_info:$fix_info" } check_fix send_logs
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦