在/etc/security/limits.conf
追加如下内容:
* soft core unlimited
* hard core unlimited
* soft nproc 1000000
* hard nproc 1000000
* soft nofile 1000000
* hard nofile 1000000
* soft memlock 32000
* hard memlock 32000
* soft msgqueue 8192000
* hard msgqueue 8192000
ubuntu需要将*替换为root,不支持*号。
- core 限制核心文件大小 Kb
- nproc 最大进程数
- nofile 可以打开的最大文件描述符数量
- memlock 最大锁定内存地址空间 (KB)
- msgqueue 消息队列使用的最大内存 (bytes)
在文件最上面提示了这句话
This file sets the resource limits for the users logged in via PAM.It does not affect resource limits of the system services.
此文件为通过PAM登录的用户设置资源限制。它不影响系统服务的资源限制
对于使用systemd托管的服务,不起作用,可以在具体的service文件中增加LimitNOFILE=65535
修改进程的资源限制。
可以通过命令
cat /proc/PID/limits
查看进程具体资源限制