LNMP VPS Server Delete MySQL log files three ways

Source: Internet
Author: User
Tags centos vps vps vps server

I in an article on the famous LNMP host one-click Installation Tool, compared to the military elder brother Lnmp and AMH host difference, because AMH has user background interface, easy to novice operation, it is recommended.

However, last weekend my website down, received dnspod sent to the downtime reminder, had to climb up in the middle of the night to deal with the VPS problem, the final reason is the AMH run produced a large number of MySQL database binaries, 25GB of the VPS hard disk nearly full, resulting in the site is unstable, there are 502 downtime error.

AMH the author gives the solution, I do not like, in fact, the background modification configuration is good. Considering the convenience of all LNMP VPS users, I have listed all the solutions to you for reference:

AMH background panel close MySQL Log

This method is the simplest, login AMH host background panel, click the top menu bar mysql--parameter configuration-whether to open the MySQL binary log, input off, save, done.

Cron task periodically deletes logs

This is AMH the author gives the scheme, I am very dissatisfied, did not consider the VPS configuration environment, if you directly to use, definitely a problem.

Create a new dellog.sh under/home
Content is

    1. #!/bin/bash
    2. CD/
    3. rm/home/usrdata/mysql*/mysql-bin*-F #删除MySQL日志
    4. Rm/home/wwwroot/*/logs/*.log-f #删除网站日志
    5. AMH nginx Restart #Nginx重启
    6. AMH MySQL Restart #MySQL重启

Then execute the command.

    1. chmod 755/home/dellog.sh

Final Execution command

    1. Crontab-l

Add content

    1. 0 4 1 * */home/dellog.sh

Then the system will automatically delete all log files at 1th # 4 o'clock in the morning every month.

Description

1 MySQL log file location to modify itself, for example, I use a CentOS VPS, after installing AMH, the file location is in/usr/local/mysql/data/

2 Rm/home/wwwroot/*/logs/*.log-f #删除网站日志 This is not right, the site default directory is actually/home/wwwroot/*/log/

3 cron task, AMH the author gives is deleted once a month, according to my site, almost two days, the log is full of the entire VPS hard drive, proposed to modify the daily 4 o'clock in the morning delete a log, that is, 0 4 * * */home/dellog.sh

Remind you to take a few minutes to learn about the crontab time parameter setting, which has five fields, namely minute, hour, number, month, week:

Modify the MySQL configuration file

This is the most thorough and versatile way to permanently shut down the MySQL log file output (reference source).

1. Delete MySQL binary log

    1. # mysql-uroot-ppassword-e "Reset master;"

2. Turn off binary logging

    1. Vi/etc/my.cnf

Note the following code:

    1. Log-bin=mysql-bin
    2. Binlog_format=mixed

3. Restart the MySQL server

Service mysqld Restart

VPS Recommended SSD Digitalocean (registered to send $10) Old Japanese computer room Linode ultra-high cost-effective vultr

LNMP VPS Server Delete MySQL log files three ways

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.