Apache: No space left on device: Couldn’t create accept lock

昨天启动内部服务器的apache时,没启动成功,看了下/var/log/httpd/error_log,有如下错误:
“[Mon Aug 06 09:32:20 2012] [emerg] (28)No space left on device: Couldn’t create accept lock (/etc/httpd/logs/accept.lock.6399) (5)”

开始根据提示去找磁盘空间不足,发现磁盘空间充足,所以这里的“no space”不是指磁盘空间。

后来发现原因是一些IPC的资源占用问题,先用”ipcs”命令查一下当前用于已经使用了的信号量集合(semaphore sets),再用“sysctl”命令查询一下每个用户最多可使用的信号量,发现基本上占用完了,不能给新的apache进程使用了(尽管没有完全占满,但是httpd.conf文件中写了已开始启动8个server进程的,确实不够分配)。

View Code BASH
1
2
3
4
5
6
7
8
9
10
11
12
13
[root@vmm-web ~]# ipcs -s | grep apache
0x00000000 10649601   apache    600        1
0x00000000 10616834   apache    600        1
0x00000000 10682371   apache    600        1
0x00000000 10715140   apache    600        1
0x00000000 10747909   apache    600        1
0x00000000 10780678   apache    600        1
0x00000000 10813447   apache    600        1
0x00000000 10846216   apache    600        1
#有很多,大约有120行;当然如果不是apache账号启动的apache,需要根据实际情况灵活变通
 
[root@vmm-web ~]# sysctl kernel.sem
kernel.sem = 250        32000   32      128

我已经确定apache这个账号下的semaphores是不用了(除了给我的HTTPD服务器),所以只需要用“ipcrm -s”命令kill掉这些semaphore array即可,做了一个小脚本如下:

View Code BASH
1
2
3
4
5
sem_list=$(ipcs -s | grep apache | awk '{print $2}')
for i in $sem_list
do
        ipcrm -s $i
done

另外,也可以设置更改每个用户的semaphore array的最大数量,先查询后更改如下。

View Code BASH
1
2
3
4
5
6
7
8
9
10
11
12
13
[root@vmm-web ~]# ipcs -s -l
 
------ 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
[root@vmm-web ~]# sysctl kernel.sem
kernel.sem = 250        32000   32      128
[root@vmm-web ~]# sysctl kernel.sem="250 256000 32 1024"
[root@vmm-web ~]# sysctl kernel.sem
kernel.sem = 250        256000  32      1024

当然如果想让此更改永久生效,可以编辑“/etc/sysctl.conf”配置文件加上设置“sysctl kernel.sem = 250 256000 32 1024”,然后执行”sysctl -p”命令加载配置文件即可。

一些简单的知识和命令记录一下。

View Code BASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@vmm-web ~]# 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 = 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 = 16
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536
 
[root@vmm-web ~]# cat /proc/sys/kernel/msgmni
16
[root@vmm-web ~]# cat /proc/sys/kernel/sem
250     256000  32      1024

而其中kernel.sem参数的四个值分别表示:Parameters meaning:
SEMMSL – semaphores per ID
SEMMNS – (SEMMNI*SEMMSL) max semaphores in system
SEMOPM – max operations per semop call
SEMMNI – max semaphore identifiers
关于msgmni解释如下:
The parameter “msgmni” is the number of message queue ids available to the system. Each message queue requires one id. msgget() gives the error ENOSPC if all the ids have been used up.
而ipcs和ipcrm的用途如下:
ipcs – report XSI interprocess communication facilities status
ipcrm – remove an XSI message queue, semaphore set, or shared memory segment identifier

后记:
后来才发现,2010年在阿里时也处理过这个问题的,当时用了别人的一个脚本来处理的,更多信息可参考如下的博客链接。


Linux IPC资源清理 : http://www.51testing.com/?uid-225738-action-viewspace-itemid-222385


http://smilejay.com/2012/08/apache_create_accept_lock/ 



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值