这发生在 Ubuntu Release 12.04(精确)64 位内核 Linux 3.2.0-25-virtual
我正在尝试增加允许用户打开的文件数。这适用于我的 eclipse java 应用程序,其中 1024 的当前限制是不够的。
根据到目前为止我发现的帖子,我应该能够将行放入
/etc/security/limits.conf 像这样:
soft nofile 4096
hard nofile 4096
Run Code Online (Sandbox Code Playgroud)
增加允许所有用户打开的文件数。
但这对我不起作用,我认为问题与该文件无关。
对于所有用户,默认限制为 1024,无论 /etc/security/limits.conf 中的内容如何(更改该文件后我重新启动)
$ ulimit -n
1024
Run Code Online (Sandbox Code Playgroud)
现在,尽管 /etc/security/limits.conf 中的条目我无法增加:
$ ulimit -n 2048
Run Code Online (Sandbox Code Playgroud)
-bash: ulimit: open files: cannot modify limit: Operation not allowed 奇怪的是我可以向下改变限制,但不能向上改变 - 甚至回到低于原始限制的数字:
$ ulimit -n 800
$ ulimit -n
800
$ ulimit -n 900
-bash: ulimit: open files: cannot modify limit: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
作为 root,我可以将限制更改为任何我想要的,向上或向下。它甚至似乎都不关心 /proc/sys/fs/file-max 中所谓的系统范围限制 …
我已经运行ulimit -n 65536,将以下行添加到/etc/security/limits.conf:
* soft nofile 65536
* hard nofile 65536
alix soft nofile 65536
alix hard nofile 65536
root soft nofile 65536
root hard nofile 65536
Run Code Online (Sandbox Code Playgroud)
并添加session required pam_limits.so到两者中:
并且fs.file-max = 65536到/etc/sysctl.d/60-file-max.conf。
尽管如此,ulimit -n在我的会话重新启动并运行后,我只得到 4096(之前是 1024)。
我错过了什么?
nofile尽管遵循了与此问题相关的每个 StackExchange 答案,但我似乎无法在 Ubuntu 14.04 上增加非 root 用户的限制。到目前为止,我有:
$ cat /etc/security/limits.d/custom.conf
@www-data hard nofile 50000
@www-data soft nofile 50000
# even tried specifying the username directly:
myuser hard nofile 50000
myuser soft nofile 50000
$ grep 'limits' /etc/pam.d/common-session*
/etc/pam.d/common-session:session required pam_limits.so
/etc/pam.d/common-session-noninteractive:session required pam_limits.so
$ cat /proc/sys/fs/file-max
101232
Run Code Online (Sandbox Code Playgroud)
重新启动,登录,并且:
$ ulimit -n 4097
-bash: ulimit: open files: cannot modify limit: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
对于非 root 用户,似乎仍然有最大 4096 的限制。
我的问题可能与 Ubuntu 无关,但由于我的桌面运行此操作系统,因此我来到了此论坛。
我正在尝试使用以下ulimit -c命令更改核心文件大小:
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7959
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes …Run Code Online (Sandbox Code Playgroud) 我似乎无法弄清楚究竟需要什么才能为所有用户永久提升最大数量的文件描述符。
/etc/security/limits.conf:
root hard nofile 1500000
root soft nofile 1000000
root hard nproc 15000
root soft nproc 10000
* hard nofile 1500000
* soft nofile 1000000
* hard nproc 15000
* soft nproc 10000
Run Code Online (Sandbox Code Playgroud)
我已将以下内容放入/etc/pam.d/common-session:
session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
重新启动后,登录为任何用户和发行ulimit -n导致1024。
之后,我尝试要求pam_limits.so到/etc/pam.d. 重新启动。登录。没有这样的运气。
如果我发出命令ulimit -n 1000000,然后检查,限制是否按预期设置。所以,我把@reboot ulimit -n 1000000成crontab -e。重新启动。登录。没有运气。
我检查/etc/ssh/sshd_config并启用了 PAM。
我尝试在每次重新启动时设置限制:
/sbin/sysctl -w fs.file-max=1000000
/sbin/sysctl -p
Run Code Online (Sandbox Code Playgroud)
没运气。
我有一台有大量并发流量的服务器,需要这么高的限制,因为服务器需要很长时间才能清除文件描述符。我该怎么做才能永久提高文件描述符限制?
作为普通用户,我想增加核心转储文件的最大大小限制。使用bash,我可以这样设置:
$ ulimit -c 100
Run Code Online (Sandbox Code Playgroud)
第一次设置时效果很好。但是,下次使用该命令时,我只能将此限制设置为不超过 100 的值。一般而言,我只能在登录后第一次使用此命令时将其设置为任意值。接下来的所有时间,可能的值都受初始设置值的限制。
如何在命令的多次使用中保持这种持久性?
我尝试mpiexec -16 ...在 384 GB RAM 服务器上执行,但它引发了 OOM Killer 并被中止。
如何为mpiexec执行设置内存限制?
我知道ulimit,但它可能会影响其他进程。
谢谢你。
我有一个新贵的工作,偶尔会因分段错误而崩溃,我有一些关于核心转储的问题。
首先,我应该添加一个节:
limit core unlimited unlimited
Run Code Online (Sandbox Code Playgroud)
允许无限制的内核大小是否有缺点?有限的限制会更好吗?
二、核心文件会去哪里?如果默认值不是标准或逻辑位置,我如何让它显示在其他地方?
我刚刚意识到我的系统没有正确限制每个用户的进程数量,因此不会阻止用户进行分叉炸弹并使整个系统崩溃:
user@thebe:~$ cat /etc/security/limits.conf | grep user
user hard nproc 512
user@thebe:~$ ulimit -u
1024
user@thebe:~$ :(){ :|:& };:
[1] 2559
user@thebe:~$ ht-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
-bash: fork: Cannot allocate memory
...
Connection to thebe closed by remote host.
Run Code Online (Sandbox Code Playgroud)
这是一个错误还是为什么它忽略了限制limits.conf,为什么不应用ulimit -n声称的限制?
PS:我真的不认为在进程限制之前达到内存限制。这台机器有 8GB 内存,当我扔下叉形炸弹时,它只使用了 4%。 …
从man time:
M Maximum resident set size of the process during its lifetime, in Kilobytes.
Run Code Online (Sandbox Code Playgroud)
从ulimit -a:
max memory size (kbytes, -m) unlimited
Run Code Online (Sandbox Code Playgroud)
但“千字节”可能意味着 1000 或 1024 字节。我猜这是一轮 1024,但我想确定一下。权威参考将不胜感激。
请随意将我的问题改写为:执行time并ulimit符合 IEC 建议,或使用 kibibyte 含义中的“kilobyte/kbyte”。