使用命令启动httpd:service httpd start 失败
查看日志文件/var/log/httpd/error_log,里面显示内容:No space left on device: AH00023: Couldn't create the ssl-cache mutex
网上搜索一番,说这个是由于semaphores(信号量) 文件太多,达到了系统的上限。
需要使用ipcs等命令进行验证,ipcs命令是什么用途呢,通过man ipcs 看一下ipcs命令的各项解释:
查询信号量,则跟上 -s 参数即可,先统计下信号量总共使用了多少,命令如下:
ipcs -s | wc -l
输出内容:
130
再查看一下系统配置的信号量参数值,使用命令:
cat /proc/sys/kernel/sem
输出内容:
[root@localhost /root]# cat /proc/sys/kernel/sem
250 32000 32 128
上面四个值分别代表什么意思呢,请见下文:
This file contains 4 numbers defining limits for System V IPC semaphores. These values represent SEMMSL, SEMMNS, SEMOPM, and SEMMNI. These fields are, in order:
SEMMSL - The maximum number of semaphores in a sempahore set.
SEMMNS - A system-wide limit on the number of semaphores in all semaphore sets. The maximum number of sempahores in the system.
SEMOPM - The maximum number of operations in a single semop call
SEMMNI - A system-widerff limit on the maximum number of semaphore identifiers (sempahore sets)
也可以使用如下命令 ipcs -ls 查看信号量的限制:
[root@localhost /root]# ipcs -ls
------ 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
简单描述一下:信号量在创建时分信号量集和信号量的概念,该命令的查询结果中,Semaphore Arrays下面每一行代表一个信号量集,其中perms对应信号量集的权限,nsems对应信号量集中信号量的个数。举例如下:
[root@localhost /root]# ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 18612224 apache 600 1
0x00000000 18644993 apache 600 1
0x00000000 18579458 apache 600 1
0x00000000 18677763 apache 600 1
0x00000000 18710532 apache 600 1
0x00000000 18743301 apache 600 1
通过前面输入 ipcs -s | wc -l 的结果得到目前的信号量集已经有130个,系统限制为128,由此导致httpd起不来。
解决办法:
- 修改系统的默认配置,就是前面查看的文件:/proc/sys/kernel/sem,比如,将128改为256:
echo 250 32000 100 256 > /proc/sys/kernel/sem
或者
- 使用命令将信号量集清理一下:
ipcs -s | grep apache | awk '{ print $2 }' | xargs -n 1 ipcrm -s
这里使用到了ipcrm 命令,查看其帮助文档如下:
所以, ipcrm -s : 表示删除信号量。