Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33443
  • 博文数量: 12
  • 博客积分: 460
  • 博客等级: 下士
  • 技术积分: 125
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-18 14:19
文章分类

全部博文(12)

文章存档

2010年(12)

我的朋友
最近访客

分类: LINUX

2010-02-19 10:58:30

一下是从网上搜来的一些资料。验证通过的为绿色。验证不通过的为红色。没有验证的为灰色。(2.6kernel)

Coredump的环境设置 
    a. 打开/关闭系统对core文件的限制
       使用ulimit -c命令可查看core文件的生成开关。若结果为0,则表示关闭了此功能,不会生成core文件。使用ulimit -c filesize命令,可以限制core文件的大小(单位为kbyte)。若ulimit -c unlimited,则表示core文件的大小不受限制。
       这句话不严谨。ulimit 显示unlimited 以后不一定能够产生coredump。
ulimit -a
core file size          (blocks, -c) 0  ----------------》 不会产生coredump,但是输入ulimit 会显示unlimted
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 16128
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) 16128
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
    b.  对于Coredump路径和文件名格式设置 (注意,必须是有效的路径,否则不会产生coredump!!!)
     /proc/sys/kernel/core_pattern 文件可以控制core文件保存位置和文件名格式。可通过以下命令修改此文件:
echo "/tmp/core-%e-%p-%t" > /proc/sys/kernel/core_pattern,可以将core文件统一生成到/corefile目录下,产生的文件名为core-命令名-pid-时间戳,以下是参数列表:
    %p - insert pid into filename 添加pid
    %u - insert current uid into filename 添加当前uid
    %g - insert current gid into filename 添加当前gid
    %s - insert signal that caused the coredump into the filename 添加导致产生core的信号
    %t - insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间
    %h - insert hostname where the coredump happened into filename 添加主机名
    %e - insert coredumping executable name into filename 添加命令名
  
    c. /proc/sys/kernel/core_uses_pid 文件可以控制core文件的文件名中是否添加pid作为扩展。文件内容为1,表示添加pid作为扩展名,生成的core文件格式为core.xxxx;为0则表示生成的core文件同一命名为core。

可通过以下命令修改此文件:  echo "1" > /proc/sys/kernel/core_uses_pid
   
    d. 在/etc/sysctl.conf(重启后生效)文件里头修改coredump配置参数:
        kernel.core_pattern = ./core_%e_%s_%t
        kernel.core_uses_pid = 1
阅读(953) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~