ITPub博客

首页 > 应用开发 > IT综合 > limit.conf与修改资源限制

limit.conf与修改资源限制

原创 IT综合 作者:liubo2010 时间:2009-11-27 12:55:30 0 删除 编辑

今天一同事反映服务器中运行的程序报资源不够的错误,程序运行在bireport用户下。

登陆服务器查看限制信息。
#ulimit -a

[@more@]

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 102400
cpu time (seconds, -t) unlimited
max user processes (-u) 40480
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

直接在命令行中修改,使用命令
#ulimit -HSi 2048
#ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 2048
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 102400
cpu time (seconds, -t) unlimited
max user processes (-u) 40480
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

但在bireport下,看到的还是没有修改前的信息
$ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 102400
cpu time (seconds, -t) unlimited
max user processes (-u) 40480
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

为什么修改不生效呢,我测试了一下,通过root账户su - bireport下,看到的信息为已经修改成功。

修改/etc/security/limits.conf ,增加下面信息
bireport soft nproc 40480
bireport hard nproc 40480
bireport soft nofile 65536
bireport hard nofile 65536
bireport - sigpending 2048

添加后,在bireport下,看到的还是没有修改前的信息
$ulimit -a


后来发现一个网友的一篇文章。
http://blog.chinaunix.net/u2/64804/showart.php?id=2024316
limit.conf是pam架构的东东,这和SSH登陆通过sshd fox出的进程有关。

可以通过在bireport的crontab 中增加ulimit -a >> /tmp/print_ulimit.log,查看该用户的资源限制实际上已经被修改过了。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22927800/viewspace-1029121/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    8
  • 访问量
    11638