How MySQL checks if the binary log files in the physical disk are missing

Source: Internet
Author: User
Tags log sort

Problem Scenario: Sometimes the binary files on the disk are deleted because of disk corruption or human error, causing the show binary logs record in MySQL to not match the binaries in the actual physical disk

#binlogdiff. SH #!/bin/sh #ocpyang @126.com #作用: Show binary logs records binary log files and actual physical file comparisons in MySQL, check #磁盘中对应的二进制日志文件是否有丢失 Source/usr/local/mysql/scripts/mysql_env.ini binlog_init=tmpinit. ' Date +%y%m%d%h%m%s '. txt Binlog_midd=tmpmidd . ' Date +%y%m%d%h%m%s '. txt #mysql中show binary logs log file binlog_res=tmpres. ' Date +%y%m%d%h%m%s ' txt # Binlog log files in a physical disk path my_cnf=/usr/local/mysql/my.cnf #mysql的配置文件 log_bin_path= ' grep-i ^log-bin ' $my _cnf |cut-d  =-F 2 ' log_bin= ' dirname $log _bin_path ' #lookup binlog records in MySQL mysql-h${mysql_host}-u${mysql_user} -p${mysql_pass}-e "show binary logs;" >${binlog_init} Cat ${binlog_init} | Cut-f 1 |cut-d. -F 2 |grep-i ' ^[0-9] ' |sort-n >${binlog_midd} #lookup binlog records in Disk Ls-t ${log_bin}| grep ' ^mysql-bin ' |cut-d.  
-F 2 |grep-i ' ^[0-9] ' |sort-n >${binlog_res} diff-c ${binlog_midd} $binlog _res #clean temp file RM-RF ${binlog_init} rm-rf ${binlog_midd} RM-RF ${binlog_res} 

This column more highlights: http://www.bianceng.cn/database/MySQL/

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.