centos7系统执行命令报错-bash: fork: Resource temporarily unavailable
报错代码:-bash: fork: Resource temporarily unavailable
线程太多资源暂时不可用
解决方法:
重启云服务器
使用命令查看系统的进程总数:
ps -ef | wc -l
ps -ef | grep www | wc -l //查看www用户的进程总数
lsof -u www | wc -l //显示所属user进程打开的文件
vim /etc/security/limits.d/20-nproc.conf
修改配置 /etc/security/limits.d/90-nproc.conf 增加 www 用户的进程最大限制
增加“ nproc”参数的值 用户或所有用户位于 /etc/security/limits.d/90-nproc.conf
>这是/etc/security/limits.d/90-nproc.conf文件的示例。
<user> - nproc 2048 <<<----[ Only for "<user>" user ]
* - nproc 2048 <<<----[ For all user's ]
应根据要求将nproc值从当前值增加到两倍或三倍。
ulimit -a //查看最大限制数是否修改成功
reboot //重启
示例配置文件内容
[www@vps root]$ cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
#* soft nproc 102400
root soft nproc unlimited
www soft nproc 102400
* soft nproc 655350
* hard nproc 655350
* soft nofile 655350
* hard nofile 655350