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
- #!/bin/bash
- CD/
- rm/home/usrdata/mysql*/mysql-bin*-F #删除MySQL日志
- Rm/home/wwwroot/*/logs/*.log-f #删除网站日志
- AMH nginx Restart #Nginx重启
- AMH MySQL Restart #MySQL重启
Then execute the command.
- chmod 755/home/dellog.sh
Final Execution command
- Crontab-l
Add content
- 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
- # mysql-uroot-ppassword-e "Reset master;"
2. Turn off binary logging
- Vi/etc/my.cnf
Note the following code:
- Log-bin=mysql-bin
- 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