预上线环境测试人员发现磁盘空间沾满,于是使用df -h 和 du -sh * 找到了大文件,并删除。
但并未释放空间,df -h 还是显示占用率为100%,此时du -sh * 显示占用只有7G,与df -h 查看到的内容不符。
在Linux或者Unix系统中,通过rm或者文件管理器删除文件将会从文件系统的目录结构上解除链接.然而如果文件是被程序占用的,则无法真正的清理磁盘空间,文件还是物理存在的。
此时使用lsof | grep deleted 查看
[root@web03.stg /]# lsof | grep deleted
mingetty 921 root txt REG 202,1 15256 138316 /sbin/mingetty (deleted)
mingetty 923 root txt REG 202,1 15256 138316 /sbin/mingetty (deleted)
mingetty 925 root txt REG 202,1 15256 138316 /sbin/mingetty (deleted)
mingetty 927 root txt REG 202,1 15256 138316 /sbin/mingetty (deleted)
mingetty 929 root txt REG 202,1 15256 138316 /sbin/mingetty (deleted)
mingetty 931 root txt REG 202,1 15256 138316 /sbin/mingetty (deleted)
AliYunDun 4170 root 6w REG 202,1 1544 3595 /usr/local/aegis/aegis_update/data/data.1 (deleted)
AliYunDun 4170 root 12w REG 202,1 614 3571 /usr/local/aegis/aegis_update/data/data.1 (deleted)
AliHids 12357 root 6w REG 202,1 1544 3595 /usr/local/aegis/aegis_update/data/data.1 (deleted)
AliHids 12357 root 12w REG 202,1 614 3571 /usr/local/aegis/aegis_update/data/data.1 (deleted)
AliYunDun 25564 root 6w REG 202,1 1544 3595 /usr/local/aegis/aegis_update/data/data.1 (deleted)
AliYunDun 25564 root 12w REG 202,1 614 3571 /usr/local/aegis/aegis_update/data/data.1 (deleted)
java 29907 application 1w REG 202,1 12423852032 141055 /opt/huoqiu/logs/minority_subject_task/minority_subject_task_buyQueueHandleTask-20160914.log (deleted)
java 29907 application 2w REG 202,1 12423852032 141055 /opt/huoqiu/logs/minority_subject_task/minority_subject_task_buyQueueHandleTask-20160914.log (deleted)
程序正在打开被删除的文件,重启程序后发现空间已被清理,df -h 与 du -sh 查看到的内容相符。
原文地址:http://11413817.blog.51cto.com/11403817/1865480