To troubleshoot a MySQL problem that is caused by a log full space

Source: Internet
Author: User

Received a monitor message today that blog access failed. Open the page a look, the huge 502 bad gateway,ping a VPS found is pass, SSH connection up to see the Nginx log found no problem, restart Lnmp when found MySQL, the problem source basically found.

The code is as follows Copy Code

Tail/usr/local/mysql/var/slyar.err

Look at the error log MySQL, the unexpected situation appears ...

Disk is full writing './mysql-bin.~rec~ ' (errcode:28). Waiting for someone. (Expect up to secs delay for server to continue after freeing disk spaces)

Amazing situation, incredibly because the disk is full, unable to write to the log caused MySQL not to start

The code is as follows Copy Code

root@slyar# DF
FileSystem 1k-blocks Used Available use% mounted on
/DEV/SDA1 3016688 2877540 0 100%/

Sure enough, the/var catalog exploded.

  code is as follows copy code

root@slyar:/ usr/local/mysql/var# ll--BLOCK-SIZE=MB
Total 504MB
-rw-rw----1 mysql mysql 26MB June June mysql-bin.000011
-RW-RW----1 MySQL mysql 5MB June mysql-bin.000012
-RW-RW----1 mysql mysql 27MB Aug 8 mysql-bin.000013-rw-rw----1 mysql mysql 43MB Aug mysql-bin.000014
-rw-rw----1 mysql mysql 270MB Feb 9 17:05 mysql-bin.000 020
-rw-rw----1 mysql mysql 115MB Apr 12:27 mysql-bin.000021
-rw-rw----1 mysql mysql 1MB Feb ten 12:07 Mysql-b In.index
-RW-RW----1 mysql mysql 0MB Apr 12:34 mysql-bin.~rec~

Basically, it's all over the stuff. mysql manual found that these things are not useful, direct deletion (this operation is best done when the MySQL service is stopped, because the current log can not be used to delete, and may cause some other problems, but with Mysql>reset Master command to clear the log directly)

The code is as follows Copy Code

root@slyar:/usr/local/mysql/var# rm-f mysql-bin.*

To prevent such a situation from recurring, turn off MySQL's log-bin log function directly

The code is as follows Copy Code

Vim/etc/my.cnf

Found it:

The code is as follows Copy Code
Log-bin=mysql-bin
Binlog_format=mixed

In front Plus # comment out,: Wq Save exit

At last

The code is as follows Copy Code

/etc/init.d/mysql restart

Start the MySQL service, everything is OK.

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.