Last update at :2024-05-26,Edit by888u
Tutorial:VPS Linux host to view the hard disk sizeAnd clean up junk filesMYSQL logFile method
1. Check the hard disk size of VPS linux host
Take a Linode VPS as an example, equipped with centos 6.5 24G hard drive First, enter: 1. df -hl Check the hard disk size and remaining space, displayed in M 2. du -sm to view the number of folders 3. du [detailed explanation of parameters] -a lists all files and directories, the default value is the value of the directory listed -b The listed values are output in b -c Finally find the total -k listed values are output in KB -m The listed values are output in mb -s only lists the final total value
2. VPS linux cleans up junk files and MYSQL log files
As above, we found that the hard drive of this VPS is full, which is a bit strange. How can there be a large hard drive usage when only a small blog with a daily IP of a few hundred is placed. Nothing could be found in the AMH panel, and it was eventually discovered that it was caused by a problem with the MYSQL database.
It is estimated that some log files take up a lot of space, so I will eliminate them step by step through the following methods.
1. Switch to the / directory and run the command du -h –max-depth=1
2. Find the folder that takes up a lot of space, then switch to this directory, further execute du -h –max-depth=1, and then continue to enter, execute, enter, and execute. . . .
3. Finally, I found the var directory under the mysql installation directory. It occupies more than 7G. I went in and looked at it. They were all mysql-bin.000XXX files. This was caused by mysql turning on the log. For a small blog like ours, it is not necessary. The generated logs take up a lot of space, so it is better to turn it off. Next, clear the log file first.
4. Open mysql and execute /usr/local/mysql/bin/mysql -u root -p
5. Clear the log file under mysql and execute reset master;
6. Okay, exit mysql and take a look at the disk space to see if it has increased a lot.
7. In order to turn off the logging function of mysql once and for all, first find the mysql configuration file and execute find / -name my.cnf
8. Found that the configuration file is in /etc/my.cnf, open it with vi, and switch to editing mode
9. Find the following location
# Replication Master Server (default) # binary logging is required for replication log-bin=mysql-bin
# binary logging format – mixed recommended binlog_format=mixed Comment out log-bin=mysql-bin and binlog_format=mixed, then save and exit
10. Restart mysql and execute /etc/init.d/mysql restart
The basic problem has been solved here, but the fundamental problem has not been solved, that is, mysql logs will still be generated, so we still need to find a way to fundamentally remove these log files. The most direct way is to stop mysql. Keep these logs.
The configuration information of Mysql is stored in the file my.cnf. We first pass:
Shell1 | fine / –name my.cnf |
Find the storage location of the my.cnf file, usually in /etc/my.cnf. Find: log-bin=mysql-bin and comment it out and restart mysql to take effect! In this way, the mysql-bin series log files will not be generated. At this point, the problem is solved.
Recommended site searches: domain name query, domain name query, cloud virtual host application for free space and domain name, me domain name, registration password retrieval, icp registration website, free virtual host application, vps dynamic ip server, Wanwang domain name space, < /p>
发表评论