httpd dead but subsys locked

网站服务器突然不能上,登上服务器发现httpd服务不能shutdown,报如下错误:
httpd dead but subsys locked ;
把/var/lock/subsys/下的httpd删除重启httpd服务也不行,查看/var/log/httpd/error_log发现错误如下
:No space left on device:Couldn't create acceptlock ; 解决办法如下:
1.首先确定你的磁盘空间是否真的不足或者已经达到配额;


2.如果磁盘空间还很充足或配额也够,那么apache能产生’acceptlock‘的另一个原因是semaphore,
semaphore是一个内部用于与其子进程进行交流的工具,"No spaceleft on device:
Couldn't create accept lock
"的意思是说apache不能再创建新的semaphore进程。
用如下命令查看有多少semaphore在运行。


#ipcs-s 你将会看到

------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 68681743 apache 600 1
0x00000000 68714515 apache 600 1
0x00000000 68747291 apache 600 1

你可运行如下命令来安全的杀死每个Semaphore

#ipcrm -s<semid>

<semid>是上面ipcs-s输出的第二列值。

想要一次性将所有的Semaphore全部杀死,请运行如下命令:

for semid in `ipcs-s |awk '{print $2}'`; do ipcrm -s$semid; done

如果不能再创建更多的Semaphores:

有些时候你可能想改变系统允许创建semaphores的数量。这就需要改变内核参数。

如果你在虚拟机上运行而不能改变内核参数,请联系你的主机提供商来改变这个参数。

运行以下命令来查看当前参数:

#ipcs-l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 32768
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1

------ Semaphore Limits --------
max number of arrays = 1024
max semaphores per array = 250
max semaphores system wide = 256000
max ops per semop call = 32
semaphore max value = 32767

------ Messages: Limits --------
max queues system wide = 1024
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384

修改/etc/sysctl.conf文件,增加如下两行:

kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

运行命令# sysctl-p

使刚改的参数生效。

(kernel.msgmni该文件指定消息队列标识的最大数目,即系统范围内最大多少个消息队列。缺省设置 :16)


另外延伸到/var/lock/subsys作用


关于/var/lock/subsys目录总的来说,系统关闭的过程(发出关闭信号,调用服务自身的进程)中会检查/var/lock/subsys下的文件,逐一关闭每个服务,如果某一运行的服务在/var/lock/subsys下没有相应的选项。在系统关闭的时候,会像杀死普通进程一样杀死这个服务。通过察看/etc/rc.d/init.d下的脚本,可以发现每个服务自己操纵时都会去查看/var/lock/subsys下相应的服务。例如:[root@rrd init.d]# pwd
/etc/rc.d/init.d[root@rrd init.d]# cat syslog
#!/bin/sh
#
# syslog Starts syslogd/klogd.
#
#
# chkconfig: 2345 30 99
# description: Syslog is the facility by which many daemons use to log \
# messages to various system log files. It is a good idea to always \
# run syslog.
# securlevel: 90
# processname: syslogd klogd# Source function library.
. /etc/rc.d/init.d/functions[ -f /sbin/syslogd ] || exit 0
[ -f /sbin/klogd ] || exit 0if [ -f /etc/sysconfig/syslog ]
then
. /etc/sysconfig/syslog
else
SYSLOGD_OPTIONS="-m 0"
KLOGD_OPTIONS=""
fiRETVAL=0# See how we were called.
case "$1" in
start)
echo -n "Starting system logger: "
# we don't want the MARK ticks
daemon syslogd $SYSLOGD_OPTIONS
RETVAL=$?
echo
echo -n "Starting kernel logger: "
daemon klogd $KLOGD_OPTIONS
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/syslog
;;
stop)
echo -n "Shutting down kernel logger: "
killproc klogd
echo
echo -n "Shutting down system logger: "
killproc syslogd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/syslog
;;
status)
status syslogd
status klogd
RETVAL=$?
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
*)
echo "Usage: syslog {start|stop|status|restart}"
exit 1
esacexit $RETVAL# cd /var/lock/subsys/
# ll syslog
-rw-r--r-- 1 root root 0 Jan 27 19:20 syslog