分类: LINUX
2013-03-22 17:39:49
ulimit是linux下设定资源使用限制的工具,使用时注意以下几点:
1. shell下更改资源限制数目
单纯在shell上通过ulimit命令更改资源限制数目似乎行不通,shell退出后,再ulimit -a 发现还是系统默认的值
2. 通过更改/etc/security/limits.conf,似乎还是不行,估计是没有启动security服务吧,需要进一步验证
vi /etc/security/limits.conf
#added by zhxue for ldap
#* - nofile 65536
soft nofile 65536
hard nofile 65536
3.把ulimit命令放到进程的初始化文件中,控制单个进程的资源限制,例如:
vi /etc/init.d/ldap ,在顶部加入如下命令:
#added by zhxue for resolving "warning: too may open files"
ulimit -n 65536
查看是否更改成功:
[root@sysimages ~]# cat /proc/`pidof slapd`/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 10485760 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 268288 268288 processes
Max open files 65536 65536 files
Max locked memory 32768 32768 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 268288 268288 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
4.查看了一下其实直接在/etc/profile中加入如下命令再生效该配置文件即可更改系统的资源限制数
ulimit -n 65536