[英]How to clean up aws ec2 server?
I recently ran a report on my EC2 server and was told that it ran out of space.我最近在我的 EC2 服务器上运行了一份报告,并被告知它的空间不足。 I deleted the csv that was partially generated from my report (it was going to be a pretty sizable one) and ran
df -h
and was surprised to get this output:我删除了部分从我的报告中生成的 csv(它将是一个相当大的)并运行
df -h
并惊讶地得到以下输出:
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 7.0G 718M 91% /
devtmpfs 15G 100K 15G 1% /dev
tmpfs 15G 0 15G 0% /dev/shm
I surprised not only by how little was available/how much space was used,(I am on the /dev/xvda1
instance) but also surprised to see 2 alternative filesystems.我不仅对可用空间少/使用了多少空间感到惊讶(我在
/dev/xvda1
实例上),而且还惊讶地看到 2 个替代文件系统。
To investigate what was taking so much space, I ran du -h
in ~
and saw the list of all directories on the server.为了调查是什么占用了这么多空间,我在
~
运行du -h
并查看服务器上所有目录的列表。 Their reported size in aggregate should not be even close to 7 gb...which is why I ask "what is taking up all that space??"他们报告的总大小不应接近 7 GB ......这就是为什么我问“是什么占用了所有空间??”
The biggest directory by far was the ~
directory containing 165MB all other were 30MB and below.迄今为止最大的目录是包含 165MB 的
~
目录,所有其他目录都是 30MB 及以下。 My mental math added it up to WAY less than 7gb.我的心算把它加起来不到 7GB。 (if I understand du -h correctly, all directories within ~ ought to be included within 165MB...so I am very confused how 7 gb could be full)
(如果我正确理解 du -h, ~ 内的所有目录都应该包含在 165MB 之内……所以我很困惑 7 GB 怎么可能已满)
Anyone know what's going on here, or how I can clean up the space?任何人都知道这里发生了什么,或者我如何清理空间? Also, just out of curiosity, is there a way to utilize the devtmpfs/tmpfs servers from the same box?
另外,出于好奇,有没有办法从同一个盒子中使用 devtmpfs/tmpfs 服务器? I am running on AWS Linux, with versions of python and ruby installed
我在 AWS Linux 上运行,安装了 python 和 ruby 版本
According to this answer , it seems as though it might be because of log files getting too large.根据这个答案,似乎可能是因为日志文件变得太大。 Try run the command OP mentioned in their answer, in order to find all large files:
sudo find / -type f -size +10M -exec ls -lh {} \\;
尝试运行他们的答案中提到的命令 OP,以查找所有大文件:
sudo find / -type f -size +10M -exec ls -lh {} \\;
For me, the best option was to delete the overlay2
docker folder and to completely refresh docker to a clean state.对我来说,最好的选择是删除
overlay2
docker 文件夹并将overlay2
完全刷新到干净的状态。 It clears up more than 3GB in my case.就我而言,它清除了超过 3GB。
Important note: it will stop and remove your instances, so you need to rebuild them.重要提示:它将停止并删除您的实例,因此您需要重建它们。
In order to do that, first stop the docker engine为此,首先停止 docker 引擎
sudo systemctl stop docker
Prune and then delete the entire docker
directory (not just the overlay2
folder):修剪然后删除整个
docker
目录(不仅仅是overlay2
文件夹):
docker system prune
sudo rm -rf /var/lib/docker
Restart docker:重启泊坞窗:
sudo systemctl start docker
The engine will restart without any images, containers, volumes, user created networks, or swarm state.引擎将在没有任何图像、容器、卷、用户创建的网络或群状态的情况下重新启动。
Additionaly you can remove snap
with:另外,您可以使用以下方法删除
snap
:
sudo apt autoremove --purge snapd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.