Linux磁盘空间被占满,df和du结果不一致

用df命令查看发现磁盘空间几乎被占满了

[root@172-16-101-253 ~]# df -hl
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   36G   35G  789M   98% /
devtmpfs                 7.8G     0  7.8G    0% /dev
tmpfs                    7.8G     0  7.8G    0% /dev/shm
tmpfs                    7.8G   41M  7.8G    1% /run
tmpfs                    7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/vda1               1014M  142M  873M   14% /boot
/dev/sda1                296G  5.6G  275G    2% /data
tmpfs                    1.6G     0  1.6G    0% /run/user/0
tmpfs                    1.6G     0  1.6G    0% /run/user/1000

清理了一些文件之后用du命令查询,发现与df命令结果不一致,df查询根目录被占用35G,但du查询根目录被占用15G

[root@172-16-101-253 app]# du -h / --max-depth=1
110M    /boot
0       /dev
du: 无法访问"/proc/29830": 没有那个文件或目录
du: 无法访问"/proc/29846": 没有那个文件或目录
du: 无法访问"/proc/29847/task/29847/fd/4": 没有那个文件或目录
du: 无法访问"/proc/29847/task/29847/fdinfo/4": 没有那个文件或目录
du: 无法访问"/proc/29847/fd/3": 没有那个文件或目录
du: 无法访问"/proc/29847/fdinfo/3": 没有那个文件或目录
0       /proc
41M     /run
0       /sys
30M     /etc
64K     /root
177M    /var
288K    /tmp
1.5G    /usr
5.6G    /home
0       /media
0       /mnt
1.9G    /opt
0       /srv
5.5G    /data
15G     /

用df -i查询inode利用率,inode不够用也会有这个问题,但是inode也是够用的

[root@172-16-101-253 app]# df -i
文件系统                   Inode 已用(I)  可用(I) 已用(I)% 挂载点
/dev/mapper/centos-root  1064648   43871  1020777       5% /
devtmpfs                 2030258     441  2029817       1% /dev
tmpfs                    2033299       1  2033298       1% /dev/shm
tmpfs                    2033299     641  2032658       1% /run
tmpfs                    2033299      16  2033283       1% /sys/fs/cgroup
/dev/vda1                 524288     327   523961       1% /boot
/dev/sda1               19660800  106003 19554797       1% /data
tmpfs                    2033299       1  2033298       1% /run/user/0
tmpfs                    2033299       1  2033298       1% /run/user/1000

用lsof |grep delete检查是否存在已删除的文件被占用的情况

[root@172-16-101-253 app]# lsof |grep delete
tuned       962          root    7u      REG              253,0        4096   33565759 /tmp/ffiQAZuAc (deleted)
gmain       962  2634    root    7u      REG              253,0        4096   33565759 /tmp/ffiQAZuAc (deleted)
tuned       962  2635    root    7u      REG              253,0        4096   33565759 /tmp/ffiQAZuAc (deleted)
tuned       962  2636    root    7u      REG              253,0        4096   33565759 /tmp/ffiQAZuAc (deleted)
tuned       962  2674    root    7u      REG              253,0        4096   33565759 /tmp/ffiQAZuAc (deleted)
java      15408         admin    1w      REG              253,0 27188723880    5232071 /home/admin/app/dt-center-task/logs/rdos_task.stdout (deleted)
java      15408         admin    2w      REG              253,0       15722    5232072 /home/admin/app/dt-center-task/logs/rdos_task.err (deleted)
java      15408         admin    3w      REG              253,0    16895030    5232069 /home/admin/app/dt-center-task/logs/vertx.gc (deleted)
java      15408         admin    8w      REG              253,0     3535802    1651950 /home/admin/app/dt-center-task/logs/task_server.log (deleted)
java      15408         admin    9w      REG              253,0      564784    5232076 /home/admin/app/dt-center-task/logs/task_master.log (deleted)
java      15408         admin   10w      REG              253,0     8224694    5232075 /home/admin/app/dt-center-task/logs/task_executor.log (deleted)
java      15408  5439   admin    1w      REG              253,0 27188718604    5232071 /home/admin/app/dt-center-task/logs/rdos_task.stdout (deleted)
java      15408  5439   admin    2w      REG              253,0       15722    5232072 /home/admin/app/dt-center-task/logs/rdos_task.err (deleted)
java      15408  5439   admin    3w      REG              253,0    16895030    5232069 /home/admin/app/dt-center-task/logs/vertx.gc (deleted)
java      15408  5439   admin    8w      REG              253,0     3535802    1651950 /home/admin/app/dt-center-task/logs/task_server.log (deleted)
java      15408  5439   admin    9w      REG              253,0      564784    5232076 /home/admin/app/dt-center-task/logs/task_master.log (deleted)
java      15408  5439   admin   10w      REG              253,0     8224694    5232075 /home/admin/app/dt-center-task/logs/task_executor.log (deleted)
java      15408 10986   admin    1w      REG              253,0 27188718604    5232071 /home/admin/app/dt-center-task/logs/rdos_task.stdout (deleted)
java      15408 10986   admin    2w      REG              253,0       15722    5232072 /home/admin/app/dt-center-task/logs/rdos_task.err (deleted)
java      15408 10986   admin    3w      REG              253,0    16895030    5232069 /home/admin/app/dt-center-task/logs/vertx.gc (deleted)
此处省略N行

检查后发现删除的日志文件仍然处于被占用的状态,此时只需kill对应的进程

你可能感兴趣的:(linux,测试工程师)