本站文章总数为:165
Search Posts

linux开启coredump排查java进程异常消失

内容纲要

服务器信息

centos6.5
Linux dl 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

1.需求原因

游戏跨服服务器某次更新后 ,java进程运行一段时间进程莫名其妙消失,尸体都没有
jstack jmap 都查不出原因,最后想coredump试一下

2.开启教程

系统默认不开启

ulimit -c

会返回0

[root@dl ~]# cat /proc/sys/kernel/core_uses_pid
1
[root@dl ~]# cat /proc/sys/kernel/core_pattern
core
[root@dl ~]# ulimit -c
0

2.1core_pattern可加路径跟参数

不加core文件生成在运行程序位置

echo "/data/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
2.1.1参数说明
%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 添加可执行程序名

2.2临时开启

ulimit -c unlimited

unlimited表示不限制core文件产生大小
也可以

ulimit -c 1024000

单位Kbytes 1024000就是1000M
但是关闭终端就失效了 正常几个小时才挂 没时间一直挂着

2.3 永久开启

vi /etc/security/limits.conf

底部插入两行

* soft core unlimited
* soft hard unlimited

重启服务器

reboot

2.4排查出问题后记得关闭

因为进程异常结束会生成core文件 有时候比较大 一直不关 久了后面磁盘会爆满
删除重启

vi /etc/security/limits.conf

删除下面两行

* soft core unlimited
* soft hard unlimited

然后重启服务器

reboot

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注