在 Debian 里,ulimit 不是由 Debian 本身“定死”的,而是受 内核参数 + 系统配置 + 用户权限 共同限制。下面分情况说明你能调到多大。
ulimit 分 软限制(soft) 和 硬限制(hard):
查看当前限制:
ulimit -a
ulimit -n
cat /proc/sys/fs/nr_open
常见值:1048576(1M)cat /proc/sys/fs/file-max
通常是几百万(取决于内存)✅ 普通用户可以调到 nr_open 以下
✅ root 可以修改 nr_open 和 file-max
示例(root):
sysctl -w fs.nr_open=2097152
ulimit -n 2097152
ulimit -u
/proc/sys/kernel/pid_max 限制cat /proc/sys/kernel/pid_max
常见值:32768 或 65535✅ root 可改:
sysctl -w kernel.pid_max=65535
ulimit -s
ulimit -v # 虚拟内存
ulimit -m # RSS(现代系统基本无效)
| 资源 | 普通用户 | root |
|---|---|---|
| open files | ≤ 1M | 可 > 1M |
| nproc | ≤ pid_max | 可改 pid_max |
| stack | 几 MB | 可 GB |
| core dump | 任意 | 任意 |
| nofile 硬上限 | 受 /etc/security/limits.conf |
可突破 |
/etc/security/limits.conf* soft nofile 65535
* hard nofile 65535
⚠️ 注意:
查看:
systemctl show nginx | grep Limit
修改:
[Service]
LimitNOFILE=500000
LimitNPROC=65535
然后:
systemctl daemon-reexec
systemctl restart nginx
Debian 上 ulimit 能调多大,取决于内核参数,而不是 Debian 版本本身。
fs.nr_open(默认 1M)kernel.pid_max如果你愿意,可以告诉我:
我可以直接给你一套 可生效的配置方案。