英文:
inodes continuously increasing on linux server with Nginx and node.js application
问题 {#heading}
在 AWS EC2 上运行着一个 node.js 应用程序(用于提供 WebSockets 和 REST API 请求)的 Linux 服务器,其后面是 Nginx。问题是系统不断地耗尽了 inodes。
因此,我不得不在过去几次中增加了 EBS 卷,但我不能继续这样做,因为这不是理想的解决方案。
在从根目录开始的每个目录中运行此命令(sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n;
)后,我发现 nginx 的 /var/lib/nginx/body
目录消耗了最多的 inodes。
上述命令会输出类似以下的内容:
...
1 0065420628
1 0065420629
1 0065420630
1 0065420631
1 0065420632
1 0065420633
1 0065420634
1 0065420635
1 0065420636
1 0065420637
1 0065420638
1 0065420639
1 0065420640
1 0065420641
1 0065420642
...
如何限制这些文件的创建?Nginx 中是否有一个控制这个的配置?
另外,这个文件夹是否可以安全地删除? 英文:
I have a linux server on AWS EC2 running a node.js application (serving WebSockets and REST API requests) behind Nginx. The issue is that the system is continuously running out of inodes.
Because of that I have had to increase the EBS volume a couple of times in the pas, but I can't keep doing it since it's not the ideal solution.
On running this command (sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n;
) in each and every directory starting from the root, I found out that the /var/lib/nginx/body
directory of nginx has the highest inodes consumption.
The above mentioned command outputs something like this:
...
1 0065420628
1 0065420629
1 0065420630
1 0065420631
1 0065420632
1 0065420633
1 0065420634
1 0065420635
1 0065420636
1 0065420637
1 0065420638
1 0065420639
1 0065420640
1 0065420641
1 0065420642
...
How can I limit the creation of these files? Is there a configuration in nginx that controls that?
Also, is this a folder that can be safely deleted?
答案1 {#1}
得分: 1
I had client_body_in_file_only on;
in one of my nginx configuration that prevented the files from being cleared. I changed the config to client_body_in_file_only clean;
and cleared some inodes manually.
Here's a quick command to manually clear files older than a specific date:
$ cd /your/large/directory
$ find . -type f ! -newermt "2023-04-01" -exec rm -rf {} \;
The inodes usage has been the same since I cleaned it up and is not increasing anymore.
Thanks to @SamMason for pointing it out to this question (https://serverfault.com/q/511789/195166) in the comments 🙌 英文:
I had client_body_in_file_only on;
in one of my nginx configuration that prevented the files from being cleared. I changed the config to client_body_in_file_only clean;
and cleared some inodes manually.
Here's a quick command to manually clear files older than a specific date:
$ cd /your/large/directory
$ find . -type f ! -newermt "2023-04-01" -exec rm -rf {} \;
The inodes usage has been the same since I cleaned it up and is not increasing anymore.
Thanks to @SamMason for pointing it out to this question (https://serverfault.com/q/511789/195166) in the comments 🙌