Specific methods for checking and fixing mysql database tables
#!/bin/sh#code by scpman# function : Check and repair mysql The database table# Add this script to the timer. When the script is executed, it will read the library later , Make a list of all the tables you want to fix, and then time the fix to begin# The damaged table will be recorded in the repair process. After the repair is completed, the damaged table will be notified by email.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_logsfor dbname in $dblistdoecho $dbnamefor tb_name in `/usr/bin/find /usr/dlm_db/mysql/$dbname -type f | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}' | sort -u`domysql -u$user -p$pass $dbname<<fff>>$fix_logscheck table $tb_name;repair table $tb_name;FFFdonedoneecho `date` done>>$fix_logs}send_logs(){msgip=10.0.7.44IP=`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_fixsend_logs