The reason why the system disk space /dev/xvda1 is full

After configuring nginx, check the disk space and use df -lh to check that the system space is full. . . . .

/dev/xvda1       20G  20G  0G  100% /

Then, query the corresponding large file through du --max-depth=1 -h / and find that only 2.3G of space is occupied

I couldn't find a large file in various ways. Later, I saw in an article that it might be caused by deleting the corresponding log file when apache or tomcat was running. Suddenly I remembered that there was a small partner a few days ago. Said the space was full, I asked him to delete the log under tomcat, and then he did not restart. . . . . .

 

The reason for the problem:

When the apache/tomcat service is running, the log of the running service is cleared, which leads to the problem that /dev/xvda1 is full. In general, most services (including scripts) cannot delete log files that are currently being written while they are running.

Principle analysis:

1. The current access.log log is being occupied by the apache process.
2. Use the rm command to delete access.log, but only the file name is actually deleted (the log file application count is not 0, so the space will not be released).
3. After the access.log is deleted by the rm command, apache still writes the log to the access.log. When the apache process is started, the inode of the file has been located through the access.log, that is to say, the log is not written through access. .log, so even if access.log is deleted, apache still writes the log to the inode node where the access.log is located, resulting in increased hard disk space.
4. Because access.log is deleted, we can't find the file, and du can't find it. The hard disk is full, but we can't see which files are occupied.
Solution:

Restart the related service or program of the log file, for example, restart apache for the apache log file (as shown in the figure below, the hard disk space is occupied normally after the restart).

 

refer to:

http://www.android100.org/html/201407/27/46936.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326312480&siteId=291194637