如何找出我在 Amazon EC2 上的存储空间已满的原因? [英] How can I find out why my storage space on Amazon EC2 is full?

查看:23
本文介绍了如何找出我在 Amazon EC2 上的存储空间已满的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

[ec2-user@ip-XXXX ~]$ df -h已使用的文件系统大小 Avail Use% Mounted on/dev/xvda1 25G 25G 0 100%/tmpfs 4.0G 0 4.0G 0%/dev/shm

出于某种原因,有些东西占用了我的存储空间.

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

[ec2-user@ip-XXXX ~]$ sudo du -a/|排序 -n -r |头-n 10993580/639296/usr237284/usr/share217908/usr/lib206884/选择150236/选择/应用程序150232/选择/应用程序/当前150224/opt/app/current/[deleted].com113432/usr/lib64

我怎样才能知道是什么在占用我的存储空间?

解决方案

好吧,我认为它的一个(或多个)日志文件变得太大,需要删除/备份.我建议先处理大文件.所以找到所有大于10 MB的文件(10 MB是足够大的文件大小,你可以同样选择+1M为1MB)

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

现在您可以确定哪些原因导致了问题并相应地处理它们.

至于你原来的du -a/|排序 -n -r |head -n 10 命令,这将不起作用,因为它是按大小排序的,因此,一个大文件的所有祖先目录都会上升到金字塔,而单个文件很可能会被遗漏.>

注意:注意到在您找到的文件所在位置出现了类似的其他日志文件/二进制文件应该很简单,因此建议在包含的目录中执行 cd原始文件以清理更多相同类型的文件.您还可以使用该命令对大小大于 1MB 的文件进行迭代,以此类推.

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.

I am 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 what's eating my storage space?

解决方案

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.

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.

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天全站免登陆