您的位置:首页 > 运维架构 > Linux

问题2:CentOS 下修改 core file size 失败解决

2014-09-08 09:17 351 查看
目的:修改core file size

1. 查看当前的系统资源限制 ulimit -a

[root@10gr2 ~]# ulimit -a

core file size (blocks, -c) 0

data seg size (kbytes, -d) unlimited

scheduling priority (-e) 0

file size (blocks, -f) unlimited

pending signals (-i) 16061

max locked memory (kbytes, -l) 32

max memory size (kbytes, -m) unlimited

open files (-n) 1024

pipe size (512 bytes, -p) 8

POSIX message queues (bytes, -q) 819200

real-time priority (-r) 0

stack size (kbytes, -s) 10240

cpu time (seconds, -t) unlimited

max user processes (-u) 16061

virtual memory (kbytes, -v) unlimited

file locks (-x) unlimited

【说明】:core file size (blocks, -c) 0 这项也就是关于 core file size 的限制的内容现在是0 也就不产生core file size ,现在想将这个值改为2GB

2. 在/etc/security/limits.conf 中加入下列的内容对 core file size 进行限制

* soft core 4194304

* hard core 4194304

3. 退出当前登陆,重新登陆,通过命令 ulimit -c 进行查看设置是否成功

[root@10gr2 ~]# ulimit -c

0

【说明】:设置只对当前的登陆有效,并不是对每次的登陆都生效,那么说明更改不成功

4. 查找原因,研究了一下相关的文档,有三个因素:

In /etc/profile (Redhat)

# No core files by default

# ulimit -S -c 0 > /dev/null 2>&1

In /etc/init.d/functions (Redhat)

# make sure it doesn't core dump anywhere unless requested

#ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1

这上面两个文件的ulimit 命令注释掉(不然登录后会系统执行一遍又将其改成0)

5. 修改完上面的两项之后,保存,并且退出当前登陆,重新登陆 通过命令 ulimit -c 查看

[root@10gr2 ~]# ulimit -c

4194304

修改成功!

6. 当然,还有第三种情况,就是写到当前用户的bash_profile 里了,同样如果bash_profile 里如果有 ulimit -c 0 的话,也需要去掉,否则用户重新登陆时,都会被置为0

--END--
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: