每次重启NGINX时,都会留下两个信号量数组。 鉴于信号量是有限的共享资源 – 服务器正在不断地谨慎,尽pipe缓慢,配额限制失败。
重启时留下的信号量由拥有600的权限的“4294967295”(-1)所有。重启之后,他们不希望被传统方式删除,例如:
$ sudo ipcrm -s 5111851 cannot remove id 5111851 (Operation not permitted)
有没有人处理过这个问题? 显然,find一种通过NGINXconfiguration来停止数组孤立的方法会是太棒了,但是我不得不修改init.d脚本来清理剩下的信号量数组,所以我似乎无法使用standart ipc *工具删除它们。
有没有办法,重新启动,删除这些信号量arrays分配给一个不存在的用户?
$ sudo ipcs -st ------ Semaphore Operation/Change Times -------- semid owner last-op last-changed ... 9568370 4294967295 Not set Fri Feb 13 03:38:02 2015 <-- logrotate 9601139 4294967295 Not set Fri Feb 13 03:38:02 2015 9633908 4294967295 Not set Sat Feb 14 03:31:06 2015 9666677 4294967295 Not set Sat Feb 14 03:31:06 2015 9764982 4294967295 Not set Sun Feb 15 03:47:06 2015 9797751 4294967295 Not set Sun Feb 15 03:47:06 2015 9830520 4294967295 Not set Mon Feb 16 03:37:02 2015 9863289 4294967295 Not set Mon Feb 16 03:37:02 2015 9994362 4294967295 Not set Mon Feb 16 11:34:08 2015 <-- manual restart 10027131 4294967295 Not set Mon Feb 16 11:34:08 2015 10125436 4294967295 Not set Mon Feb 16 13:47:25 2015 10158205 4294967295 Not set Mon Feb 16 13:47:25 2015 10256510 4294967295 Not set Mon Feb 16 13:52:47 2015 10289279 4294967295 Not set Mon Feb 16 13:52:47 2015 $ nginx -V nginx version: nginx/1.6.2 TLS SNI support enabled configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-debug --add-module=/builddir/build/BUILD/nginx-1.6.2/modsecurity-2.8.0/nginx/modsecurity --add-module=/builddir/build/BUILD/nginx-1.6.2/ngx_cache_purge-2.1 --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=-Wl,-E
CentOS 6,NGINX 1.6.2。
你可能要升级到nginx 1.8 – 这为我解决了泄漏的信号量问题(至less乍一看)
我没有find问题的根源,但是这是一个解决方法。
在/etc/init.d/nginx中 ,findstop()函数并在return $retval之前添加以下行:
ipcs -s | grep "4294967295" | awk ' { print $2 } ' | xargs -I % ipcrm -s %

有了这个改变, sudo service nginx restart现在应该清除旧的信号量数组。
那么首先不能删除信号呢? 这与通过整个命令不会级联的sudo权限混淆起来。 切换到root没有遇到这样的问题。
[user@example ~]$ sudo ipcs -s | grep "4294967295" | awk ' { print $2 } ' | xargs -I % ipcrm -s % ipcrm: permission denied for id (819214) ipcrm: permission denied for id (851983) ipcrm: permission denied for id (1114130) [user@example ~]$ sudo -i [root@example ~]# ipcs -s | grep "4294967295" | awk ' { print $2 } ' | xargs -I % ipcrm -s % [root@example ~]#