Check and fix mysql database tables

Source: Internet
Author: User

Check and fix mysql database tables
01 #! /Bin/sh02 # code by scpman03 # function: Check and fix mysql database table 04 # Add the script to the schedule. When the script is executed, it will read the database, list all the tables to be repaired, and run the timer to start the repair. 05 # record the damaged tables during the repair process. After the repair is completed, send an email to notify the damaged tables. 06fix_logs = '/tmp/fix. log '07user = ''08pass = ''09check _ fix () 10 {11 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 "'12echo start' date '> $ fix_logs13for dbname in $ dblist14do15echo $ dbname16for tb_name in'/usr/ bin/find/usr/dlm_db/mysql/$ dbname-type f | awk-F '/''{print $ NF}' | awk-F '. ''{print $1} '| sort-17u '18do19mysql-u $ user-p $ pass $ dbname <fff> $ fix_logs20check table $ tb_name; 21 repair table $ tb_name; 22FFF23done24done25echo 'date' done >>$ fix_logs26} 27send_logs () 28 {29 msgip = 10.0.7.4430IP = 'cat/etc/rc. conf | grep-E "ifconfig _ [em1 | bce1]" | awk '{print "IP: "$2} '| sed-n 1 P' 31fix _ info = 'grep-rE" Error | start | done "$ fix_logs' 32/usr/bin/logger-p local1.info -h $ msgip "the services: $ IP mysql_table_fix_info: $ fix_info "33} 34check_fix35send_logs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.