很久以前,在centos6.5上有一個httpd和一個每天restart的腳本(直接kill -9 httpd再service httpd restart)。
某日,httpd 被kill之後,就沒有restart成功,/var/log/httpd/error_log中只有一句話:
configuration failed.
root用戶人工去重啟它,也是如此報錯。。。把log level設置成debug,仍然只有這一句錯誤提示。。。差點抓狂了…
最後google到了答案:
ipcs -s | grep apache | awk '{print $2;}' | while read -r line; do ipcrm sem "$line"; done
大致是由於 kill -9導致apache未釋放Semaphore Arrays,長期積累下來,達到一定程度之後,再申請新的semaphore array就會失敗。只是這個出錯提示實在是太2了。
[root@www httpd]# ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 4194303
max total shared memory (kbytes) = 1073741824
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767
------ Messages: Limits --------
max queues system wide = 1378
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536