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

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

问题描述

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

  [ec2-user @ ip-XXXX〜] $ df -h已使用的文件系统大小可用百分比已安装在/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/共享217908/usr/lib206884/opt150236/opt/app150232/选择/应用程序/当前150224/opt/app/current/[deleted].com113432/usr/lib64 

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

解决方案

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

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