错误:EMFILE:打开的文件太多,请注意,除非我使用 sudo [英] Error: EMFILE: too many open files, watch, unless I use sudo
问题描述
最近我遇到了一个问题.我无法在 element-web
目录中运行 yarn start
,我得到了这些 错误.最初我认为它与 element-web
本身有关,所以我创建了一个 问题.一段时间后,我尝试在 bibviz
中运行 wintersmith preview
目录并得到相同的错误.这很奇怪,所以我尝试创建一个 Angular 项目并再次运行 ng serve
和错误.我前往该问题以关闭它,因为它不是 element-web
问题.我发现还有另一个 issue 也有同样的问题.它已经被 turt2live
关闭,说 看起来你已经系统内存不足
.基于此,我尝试关闭大多数在后台运行的程序,现在所有命令都可以运行了.
Recently I've run into an problem. I am not able to run yarn start
in element-web
directory, I get these errors. Originally I thought it had something to do with element-web
itself so I created an issue. Some time after that I tried to run wintersmith preview
in bibviz
directory and got the same errors. This was weird so I tried to create an Angular project and run ng serve
and errors again. I headed to the issue to close it as it wasn't an element-web
issue. I found that there was another issue created with the same problem. It had already been closed by turt2live
saying it looks like you've run out of memory on your system
. Based on this I tried to turn of most programs running in the background and now all the commands worked.
我确信 ng serve
过去曾经工作过.
I am sure that ng serve
used to work in the past.
我的 PC 有 16 GB 的 RAM,当我使用 7/16 GB 时,命令已经失败.运行命令时我看不到任何内存峰值.使用 sudo
运行命令也完全消除了这个问题.这对我来说没有任何意义.
My PC has 16 GB of RAM and the commands already fail when I am on 7/16 GB. I can't see any memory spikes when running the commands. Running the commands with sudo
also completely eliminates the problem. This doesn't make any sense to me.
研究引导我使用 ulimits
但它们似乎没有效果.我也安装了 watchman
没有效果.
Research lead me to ulimits
but they seem to have no effect. I have also installed watchman
with no effect.
谁能告诉我我错过了什么?
Can someone tell me what I am missing?
先谢谢你!
我使用的是 Debian 11 Bullseye.这是一些可能有用的命令的输出.
I am on Debian 11 Bullseye. This is the output of a few commands that could be useful.
作为普通用户:
> uname -a
Linux Simon-s-PC 5.8.0-3-amd64 #1 SMP Debian 5.8.14-1 (2020-10-10) x86_64 GNU/Linux
> sudo sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 524288
> ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-m: resident set size (kbytes) unlimited
-u: processes 46482
-n: file descriptors 8192
-l: locked-in-memory size (kbytes) unlimited
-v: address space (kbytes) unlimited
-x: file locks unlimited
-i: pending signals 63664
-q: bytes in POSIX msg queues 819200
-e: max nice 0
-r: max rt priority 95
-N 15: unlimited
> yarn --version
1.22.5
使用sudo su
:
> sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 524288
> ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-m: resident set size (kbytes) unlimited
-u: processes 63664
-n: file descriptors 1024
-l: locked-in-memory size (kbytes) 2043392
-v: address space (kbytes) unlimited
-x: file locks unlimited
-i: pending signals 63664
-q: bytes in POSIX msg queues 819200
-e: max nice 0
-r: max rt priority 0
-N 15: unlimited
推荐答案
我想我已经找到了解决方案:
I think I've found a solution:
- 在
/etc/sysctl.conf
中设置限制,添加:
- Set limits in
/etc/sysctl.conf
by adding:
fs.inotify.max_user_watches=524288
fs.inotify.max_user_instances=512
打开一个新终端或使用
Open a new terminal or reload
sysctl.conf
variables withsudo sysctl --system
运行
yarn start
希望现在一切正常.如果它不起作用,请尝试将限制设置得更高.
Everything should work fine now, hopefully. If it doesn't work try setting the limits higher.
这篇关于错误:EMFILE:打开的文件太多,请注意,除非我使用 sudo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!