欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用shell檢查并修復(fù)mysql數(shù)據(jù)庫表的腳本

 更新時(shí)間:2014年03月13日 14:35:36   投稿:zxhpj  
這篇文章主要介紹了使用shell檢查并修復(fù)mysql數(shù)據(jù)庫表的腳本,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

#!/bin/sh
#code by scpman
#功能:檢查并修復(fù)mysql數(shù)據(jù)庫表
#將此腳本加到定時(shí)中,腳本執(zhí)行時(shí),等會(huì)讀庫,列出要修復(fù)的所有表,然后計(jì)時(shí),開始修復(fù)
#修復(fù)過程中將損壞的表記錄下來,修復(fù)完成后,將損壞的表,發(fā)郵件通知。
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<<fff>>$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

相關(guān)文章

最新評(píng)論