一、错误信息
2013/10/22 16:38:06 [emerg] 7278#0: setuid(502) failed (11: Resource temporarily unavailable) 2013/10/22 16:38:06 [emerg] 7279#0: setuid(502) failed (11: Resource temporarily unavailable) 2013/10/22 16:38:06 [emerg] 7280#0: setuid(502) failed (11: Resource temporarily unavailable) 2013/10/22 16:38:06 [emerg] 7281#0: setuid(502) failed (11: Resource temporarily unavailable) 2013/10/22 16:38:06 [alert] 7277#0: worker process 7278 exited with fatal code 2 and cannot be respawned 2013/10/22 16:38:06 [alert] 7277#0: worker process 7279 exited with fatal code 2 and cannot be respawned 2013/10/22 16:38:06 [alert] 7277#0: worker process 7280 exited with fatal code 2 and cannot be respawned 2013/10/22 16:38:06 [alert] 7277#0: worker process 7281 exited with fatal code 2 and cannot be respawned 2013/10/22 16:38:06 [emerg] 7282#0: setuid(502) failed (11: Resource temporarily unavailable) 2013/10/22 16:38:06 [alert] 7277#0: worker process 7282 exited with fatal code 2 and cannot be respawned
二、问题分析
1.查看502用户是否存在(之前服务一直正常运行,故502对应的用户存在),如果不存在添加运行程序的用户 grep --color '502' /etc/password 2.查看UID为502用户打开的资源数(包括进程数、文件数等) ps -U 'UID为502的用户名' | wc -l #进程数 lsof -u 'UID为502的用户名' | wc -l #文件数 3.查看UID为502用户的Ulimit配置情况 su - 'UID为502的用户名' ulimit -n 4.根据步骤2和3进行对比,进而确定是不是UID为502用户打开的文件句柄数超出最大设置 由步骤2和3的数据对比发现,UID为502的用户名最大文件句柄数为默认的‘1024’,而用户打开的文件数已经到3000多,故会出现上述错误信息
三、处理方法
1.修改UID为502的用户名ulimit cat >>/etc/security/limits.conf <<EOF www soft nproc 51200 www hard nproc 16384 www soft nofile 51200 www hard nofile 51200 2.重启nginx服务 nginx -s stop nginx
至此服务已成功启动,问题解决
转载于:https://blog.51cto.com/urchin/1314090