首先通过命令:ulimit -c 查看是否打开了core生成的开关,如果是0则表示没有生成,可以使用ulimit -c unlimited 命令来打开开关,此命令表示生成的core大小是不受限制的。但仅在shell中执行该命令,在关闭shell之后,命令会失效。
如果想在整个系统中生效,方法如下:
1) 编辑/root/.bash_profile文件,在其中加入ulitmit -S -c unlimited
2)source /root/.bash_profile
生成的core可以使用gdb 工具调试,接下来讲述gdb工具的安装。
1)首先使用uname -r 查看使用的内核版本,如
Linux 3.10.0-229.1.2.el7.x86_64 x86_64
2)去http://debuginfo.centos.org/7/x86_64/ 下载相应的rpm包,
本机内核是3.10.0-229.1.2.el7.x86_64 x86_64
下载:
- kernel-debuginfo-3.10.0-229.1.2.el7.x86_64.rpm
- kernel-debuginfo-common-x86_64-3.10.0-229.1.2.el7.x86_64.rpm
3)安装RPM包
rpm -ivh kernel-debuginfo-common-x86_64-3.10.0-229.1.2.el7.x86_64.rpm
rpm -ivh kernel-debuginfo-3.10.0-229.1.2.el7.x86_64.rpm
4)配置CentOS-Debuginfo.repo (一般云服务器上是没有该文件的,需要自己创建)
cat /etc/yum.repos.d/CentOS-Debug.repo
#Debug Info
[debug]
name=CentOS-$releasever - DebugInfo
baseurl=http://debuginfo.centos.org/$releasever/$basearch/
gpgcheck=0
enabled=1
protect=1
priority=1
5)使用debuginfo-install安装glibc
debuginfo-install glibc
6)如果提示报错-bash: debuginfo-install: command not found
yum install nss-softokn-debuginfo --nogpgchec
yum install yum-utils
7)最后安装其他包:可以根据自己的错误提示安装
debuginfo-install bzip2-libs-1.0.6-12.el7.x86_64 cyrus-sasl-lib-2.1.26-17.el7.x86_64 freetype-2.4.11-10.el7_1.1.x86_64 glibc-2.17-78.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.12.2-14.el7.x86_64 libcom_err-1.42.9-7.el7.x86_64 libcurl-7.29.0-19.el7.x86_64 libidn-1.28-3.el7.x86_64 libjpeg-turbo-1.2.90-5.el7.x86_64 libpng-1.5.13-5.el7.x86_64 libselinux-2.2.2-6.el7.x86_64 libssh2-1.4.3-8.el7.x86_64 libxml2-2.9.1-5.el7_1.2.x86_64 nspr-4.10.6-3.el7.x86_64 nss-3.16.2.3-5.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 nss-util-3.16.2.3-2.el7.x86_64 openldap-2.4.39-6.el7.x86_64 openssl-libs-1.0.1e-42.el7.4.x86_64 pcre-8.32-14.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 zlib-1.2.7-13.el7.x86_64