Amazon EC2-磁盘已满 [英] Amazon EC2 - disk full

查看:152
本文介绍了Amazon EC2-磁盘已满的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Amazon EC2服务器上运行df -h时,这是输出:

When I run df -h on my Amazon EC2 server, this is the output:

[ec2-user@ip-XXXX ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             25G   25G     0 100% /
tmpfs                 4.0G     0  4.0G   0% /dev/shm

由于某种原因,某些东西正在耗尽我的存储空间.

for some reason something is eating up my storage space.

我正在尝试查找所有大文件/文件夹 这就是我得到的:

Im trying to find all of the big files/folders and this is what i get back:

[ec2-user@ip-XXXX ~]$ sudo du -a / | sort -n -r | head -n 10
993580  /
639296  /usr
237284  /usr/share
217908  /usr/lib
206884  /opt
150236  /opt/app
150232  /opt/app/current
150224  /opt/app/current/[deleted].com
113432  /usr/lib64

我如何找出正在占用我的存储空间的东西?

How can I find out whats eating my storage space?

推荐答案

好吧,我认为它的一个(或多个)日志文件太大了,需要删除/备份.我建议先处理大文件.因此,请找到所有大于10 MB的文件(10 MB足够大的文件大小,您可以类似地为1MB选择+ 1M)

Well, I think its one (or more) logfiles which have grown too large and need to be removed/backupped. I would suggest going after the big files first. So find all files greater than 10 MB (10 MB is a big enough file size, you can choose +1M for 1MB similarly)

sudo find / -type f -size +10M -exec ls -lh {} \;

现在,您可以找出造成问题的原因并进行相应处理.

and now you can identify which ones are causing the trouble and deal with them accordingly.

至于您原来的du -a / | sort -n -r | head -n 10命令,由于它按大小排序,因此将不起作用,因此,大文件的所有祖先目录都将进入金字塔,而单个文件很可能会丢失.

As for your original du -a / | sort -n -r | head -n 10 command, that won't work since it is sorting by size, and so, all ancestor directories of a large file will go up the pyramid, while the individual file will most probably be missed.

注意:在找到的文件位置中注意到类似的其他日志文件/二进制文件的出现应该非常简单,因此建议将cd放入包含要清除的原始文件的目录中更多相同类型的文件.您也可以使用该命令来迭代文件大小大于1MB next的文件,依此类推.

Note: It should be pretty simple to notice the occurence of similar other log files/binaries in the location of the files you so find, so as a suggestion, do cd in to the directory containing the original file to cleanup more files of the same kind. You can also iterate with the command for files with sizes greater than 1MB next, and so on.

这篇关于Amazon EC2-磁盘已满的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆