Ree*_*eed 4 linux filesystems inode
尝试了几种解决方案,但只能在一定程度上起作用。 https://unix.stackexchange.com/questions/37329/efficiently-delete-large-directory- contains-thousands-of-files?newreg=07f276292205457ab9975a0ea68e9273
http://www.slashroot.in/which-is-the-fastest-method-to-delete-files-in-linux
释放 8% 的 inode 后,磁盘变得非常慢,无法再删除任何内容。
rm -f filename*
rsync -a --delete empty_dir/ yourdirectory/
perl -e 'for(<*>){((stat)[9]<(unlink))}'
Run Code Online (Sandbox Code Playgroud)
现在磁盘看起来像这样
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 2621440 2385895 235545 92% /
tmpfs 128789 1 128788 1% /dev/shm
Run Code Online (Sandbox Code Playgroud)
一个目录中仍然有 600 万个以上的小文件。上述方法以大约 2 个文件/秒的速度删除
我阅读了有关 b 树重新平衡的信息。但是如何诊断/解决缓慢删除问题?
``
一个快速的事情是移动/重命名您的当前/tmp目录并创建一个新目录,以便/tmp不再影响 的正常使用 。
mkdir /newtmp
chmod 1777 /newtmp
mv /tmp /tmp-old && mv /newtmp /tmp
Run Code Online (Sandbox Code Playgroud)
也许你也需要这样做/var/tmp。这使您可以和平地清理 /tmp-old。
作为缓解措施:
考虑使用您的一些内存来创建一个单独的 tempfs 分区以用作您的 PHP 会话文件的存储,这将在一定程度上限制对系统其余部分的影响。
IE
mkdir /var/cache/php
chmod 1777 /var/cache/php
mount -t tmpfs size=500M /var/cache/php
Run Code Online (Sandbox Code Playgroud)
并编辑您的php.ini和设置
session.save_path = "/var/cache/php"
Run Code Online (Sandbox Code Playgroud)