• notice
  • Congratulations on the launch of the Sought Tech site

Check and fix the specific method of the mysql database table

#!/bin/sh
#code by scpman
#Function: Check and repair mysql database table
#Add this script to the timing.When the script is executed, it will read the library and list all the tables to be repaired, and then time to start repairing
#Record the damaged table during the repair process.After the repair is completed, send an email notification to the damaged table.
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 

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+