{"id":727,"date":"2018-03-29T10:14:11","date_gmt":"2018-03-29T02:14:11","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=727"},"modified":"2018-03-29T10:14:11","modified_gmt":"2018-03-29T02:14:11","slug":"centos7-%e9%85%8d%e7%bd%aekdump%e5%92%8c%e4%bd%bf%e7%94%a8crash%e5%b7%a5%e5%85%b7%e5%88%86%e6%9e%90crash%e7%8e%b0%e5%9c%ba","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=727","title":{"rendered":"CentOS7 \u914d\u7f6ekdump\u548c\u4f7f\u7528crash\u5de5\u5177\u5206\u6790crash\u73b0\u573a"},"content":{"rendered":"<p>\u539f\u6587\u00a0<wbr \/>\u00a0<wbr \/><a href=\"http:\/\/smilejay.com\/2016\/04\/centos7-kdump-configuration\/?utm_source=tuicool&amp;utm_medium=referral\">http:\/\/smilejay.com\/2016\/04\/centos7-kdump-configuration\/<\/a><\/p>\n<div>\n<p>1. \u5173\u4e8ekdump \u548c crash<\/p>\n<p>kdump\u662f\u4e00\u79cdkernel crash dump\u7684\u673a\u5236\uff0c\u5b83\u53ef\u4ee5\u5728\u5185\u6838crash\u65f6\u4fdd\u5b58\u7cfb\u7edf\u7684\u5185\u5b58\u4fe1\u606f\u7528\u4e8e\u540e\u7eed\u7684\u5206\u6790\u3002kdump\u662f\u57fa\u4e8ekexec\u7684\u3002<\/p>\n<p>crash\u662f\u4e00\u4e2a\u7528\u4e8e\u4ea4\u4e92\u5f0f\u5730\u5206\u6790\u6b63\u5728\u8fd0\u884c\u7684Linux\u7cfb\u7edf\u6216\u8005kernel crash\u540e\u7684core dump\u6570\u636e\u7684\u5de5\u5177\u3002<\/p>\n<p>dump\u7684\u5de5\u4f5c\u539f\u7406\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px auto 10px; padding: 0px; border: 0px none; list-style: none; max-width: 96%; height: auto; vertical-align: middle; text-align: center; display: block;\" title=\"CentOS7\u00a0&lt;wbr&gt;\u914d\u7f6ekdump\u548c\u4f7f\u7528crash\u5de5\u5177\u5206\u6790crash\u73b0\u573a\" src=\"http:\/\/img0.tuicool.com\/euQJvaI.png!web\" alt=\"CentOS7\u00a0&lt;wbr&gt;\u914d\u7f6ekdump\u548c\u4f7f\u7528crash\u5de5\u5177\u5206\u6790crash\u73b0\u573a\" width=\"300\" height=\"193\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px auto 10px; padding: 0px; border: 0px none; list-style: none; max-width: 96%; height: auto; vertical-align: middle; text-align: center; display: block;\" title=\"CentOS7\u00a0&lt;wbr&gt;\u914d\u7f6ekdump\u548c\u4f7f\u7528crash\u5de5\u5177\u5206\u6790crash\u73b0\u573a\" src=\"http:\/\/img0.tuicool.com\/yq6FBz.jpg!web\" alt=\"CentOS7\u00a0&lt;wbr&gt;\u914d\u7f6ekdump\u548c\u4f7f\u7528crash\u5de5\u5177\u5206\u6790crash\u73b0\u573a\" width=\"300\" height=\"188\" \/><\/div>\n<div>\n<p>2. \u5728CentOS 7 \u4e2d\u914d\u7f6ekdump<\/p>\n<p>\u9700\u8981\u5728kernel\u542f\u52a8\u547d\u4ee4\u884c\u53c2\u6570\u4e2d\u6dfb\u52a0crashkernel\u53c2\u6570\uff0c\u5e76\u542f\u52a8kdump\u670d\u52a1\u3002<\/p>\n<p>\u4e00\u822c\u8bbe\u7f6e\u4e3a crashkernel=auto \u8868\u793a\u6839\u636e\u7cfb\u7edf\u5185\u5b58\u81ea\u52a8reserve\u4e00\u4e9b\u5185\u5b58\u7ed9kernelcrash\u7528\uff0c\u5728x86_64\u7cfb\u7edf\u4e2d\u5185\u5b58\u5927\u4e8e\u7b49\u4e8e2GB\u65f6\u4f1areserve\u5185\u5b58\uff0c\u6700\u5c0f\u4fdd\u7559\u5185\u5b58\u8ba1\u7b97\u65b9\u6cd5\u662f\uff1a160 MB + 2 bits for every 4 KB of RAM.<\/p>\n<p>\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u8bbe\u7f6ecrashkernel=512M\u8fd9\u6837\u7684\u56fa\u5b9a\u4fdd\u7559\u5185\u5b58\u3002<\/p>\n<\/div>\n<div>\n<p>\u7528 yum install kexec-tools \u5b89\u88c5kdump\u5de5\u5177\u548c\u670d\u52a1<\/p>\n<p>\u7528 systemctl start kdump \u547d\u4ee4\u53ef\u4ee5\u542f\u52a8kdump.service\uff0c\u7528 systemctl enable kdump \u8ba9dump\u670d\u52a1\u5728\u5f00\u673a\u65f6\u81ea\u52a8\u542f\u52a8\u3002<\/p>\n<p>kdump.service \u76f8\u5173\u7684\u914d\u7f6e\u6587\u4ef6 \/etc\/kdump.conf \u91cc\u9762\u53ef\u4ee5\u4fee\u6539\u4e00\u4e9b\u9ed8\u8ba4\u7684\u914d\u7f6e\uff0c\u6bd4\u5982dump\u5b8c\u6210\u540e\u7684\u52a8\u4f5c\uff08\u9ed8\u8ba4\u662freboot\uff09\u3001dump\u6587\u4ef6\u5b58\u653e\u7684\u65b9\u5f0f\uff08\u672c\u5730\u76ee\u5f55\u3001NFS\u3001scp\u5230\u53e6\u5916\u670d\u52a1\u5668\u7b49\uff09\u3002<\/p>\n<\/div>\n<div>\n<p>3. \u6d4b\u8bd5kdump<\/p>\n<p>\u7528root\u6743\u9650\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u8ba9kernel crash\u3002<\/p>\n<\/div>\n<div>\n<pre># echo 1 &gt; \/proc\/sys\/kernel\/sysrq\n# echo c &gt; \/proc\/sysrq-trigger\n<\/pre>\n<\/div>\n<p>kernel dump\u5b8c\u6210\u540e\uff0c\u7cfb\u7edf\u91cd\u542f\uff0c\u8fdb\u5165\u5230 \/var\/crash\/ \u76ee\u5f55\u4e0b\u53ef\u4ee5\u770b\u5230\u4fdd\u5b58\u4e0b\u6765\u7684crash\u65f6\u7cfb\u7edf\u7684\u5185\u5b58\u6570\u636e\u6587\u4ef6\u3002 \uff08\u9ed8\u8ba4\u4fdd\u5b58\u5728\/var\/crash\u76ee\u5f55\uff09<\/p>\n<div>\n<p>4. \u7528crash\u5de5\u5177\u5206\u6790<\/p>\n<p>\u9996\u5148\u9700\u8981\u5b89\u88c5\u5bf9\u5e94\u7684kernel-debuginfo\u8f6f\u4ef6\u5305\uff0c\u6bd4\u5982\uff1a<\/p>\n<p>\u8865\u5145\uff1b\u6ce8\u610f\u4e0b\u8f7d\u7684\u65f6\u5019\uff0c\u8981\u4e0b\u8f7d \u4e0e\u751f\u6210dump\u6587\u4ef6\u76f8\u540c\u7684\u5185\u6838\u7248\u672c\u7684kernel-debuginfo\u3002<\/p>\n<p>\u67e5\u770buname -a<\/p>\n<p>wget http:\/\/debuginfo.centos.org\/7\/x86_64\/kernel-debuginfo-common-x86_64-3.10.0-327.el7.x86_64.rpm<\/p>\n<p>wget http:\/\/debuginfo.centos.org\/7\/x86_64\/kernel-debuginfo-3.10.0-327.el7.x86_64.rpm<\/p>\n<\/div>\n<p>\u5b89\u88c5\u597dkernel-debuginfo\u5305\u540e\uff0c\u6267\u884c\u7c7b\u4f3c\u8fd9\u6837\u7684crash\u547d\u4ee4\u5373\u53ef\u8fdb\u5165\u4ea4\u4e92\u5f0f\u7684\u5206\u6790\uff1a<\/p>\n<div>\n<pre>crash \/usr\/lib\/debug\/lib\/modules\/3.10.0-327.el7.x86_64\/vmlinux \/var\/crash\/127.0.0.1-2016-03-28-15\\:28\\:59\/vmcore\n<\/pre>\n<\/div>\n<p>\u5728\u8f93\u5165bt\u53ef\u4ee5\u5c55\u793akernel-stack\u7684backtrace\uff0c\u66f4\u591acrash\u4e2d\u7684\u547d\u4ee4\u89c1 man crash\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u7ed9\u4e2a\u6211\u542f\u52a8kdump.service\u5931\u8d25\u7684\u60c5\u51b5\uff1a\u5185\u5b58\u8f83\u5c0f\u65f6\uff0c\u6ca1\u6709reserve\u5185\u5b58\u7ed9crashkernel\uff1b\u542f\u52a8kdump.service\u4f1a\u5931\u8d25\uff0csystemctl status kdump \u4f1a\u770b\u5230\u5982\u4e0blog:<\/p>\n<div>\n<pre>[root@localhost ~]# systemctl status kdump\n\u25cf kdump.service - Crashrecoverykernelarmin<wbr \/>g\n\u00a0<wbr \/>\u00a0<wbr \/>Loaded: loaded (\/usr\/lib\/systemd\/system\/kdump.service; enabled; vendorpreset: enabled)\n\u00a0<wbr \/>\u00a0<wbr \/>Active: failed (Result: exit-code) sinceMon 2016-03-28 14:17:21 CST; 7s ago\n\u00a0<wbr \/>\u00a0<wbr \/>Process: 29388 ExecStart=\/usr\/bin\/kdumpctlstart (code=exited, status=1\/FAILURE)\n MainPID: 29388 (code=exited, status=1\/FAILURE)\n\u00a0<wbr \/>\nMar 28 14:17:20 localhost.localdomain systemd[1]: StartingCrashrecoveryker<wbr \/>nelarming...\nMar 28 14:17:21 localhost.localdomain kdumpctl[29388]: Nomemoryreservedfor crashkernel.\nMar 28 14:17:21 localhost.localdomain kdumpctl[29388]: Startingkdump: [FAILED]\nMar 28 14:17:21 localhost.localdomain systemd[1]: kdump.service: mainprocessexited, code=exited, status=1\/FAILURE\nMar 28 14:17:21 localhost.localdomain systemd[1]: Failedto startCrashrecoverykernel<wbr \/>arming.\nMar 28 14:17:21 localhost.localdomain systemd[1]: Unitkdump.service enteredfailedstate.\nMar 28 14:17:21 localhost.localdomain systemd[1]: kdump.service failed.\n<\/pre>\n<\/div>\n<div>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<p>\u6743\u5a01\u8be6\u7ec6\u7684Redhat\u5b98\u65b9\u6587\u6863\u00a0<wbr \/><a href=\"https:\/\/access.redhat.com\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/7\/html\/Kernel_Crash_Dump_Guide\/\" target=\"_blank\" rel=\"noopener\">https:\/\/access.redhat.com\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/7\/html\/Kernel_Crash_Dump_Guide\/<\/a><\/p>\n<\/div>\n<div>\n<p><a href=\"http:\/\/thegeekdiary.com\/centos-rhel-7-how-to-configure-kdump\/\" target=\"_blank\" rel=\"noopener\">CentOS \/ RHEL 7 : How to configure kdump<\/a><\/p>\n<\/div>\n<div>\n<p><a href=\"http:\/\/www.linuxtechi.com\/how-to-enable-kdump-on-rhel-7-and-centos-7\/\" target=\"_blank\" rel=\"noopener\">How to enable Kdump on RHEL 7 and CentOS 7<\/a><\/p>\n<\/div>\n<p>http:\/\/unixadminschool.com\/blog\/2015\/07\/configuring-kdump-to-troubleshoot-kernel-crashes-hangs-or-reboots-in-rhel5rhel6rhel7\/#difference-between-chroot-pivot-root<\/p>\n<p><span style=\"color: #333333;\">\u53c2\u8003\uff1a<\/span><\/p>\n<p><span style=\"color: #333333;\">1 \u00a0<wbr \/>Systemtap \u5b89\u88c5<\/span><\/p>\n<p><span style=\"color: #333333;\">\u00a0<wbr \/>\u00a0\u00a0<wbr \/>\u00a0yum install systemtap \u00a0<wbr \/>\u00a0\u00a0<wbr \/><\/span><\/p>\n<p><span style=\"color: #333333;\">\u00a0<wbr \/>\u00a0\u00a0<wbr \/>\u00a0\u8ddfsystemtap\u6709\u5173\u7684\u67096,7\u4e2a,\u5168\u88c5\u4e0a,\u522b\u5077\u61d2<\/span><\/p>\n<p><span style=\"color: #333333;\">\u00a0<wbr \/>\u00a0\u00a0<wbr \/>\u00a0\u5c31\u7528yum\u5b89\u88c5,\u522b\u50bb\u50bb\u7684\u53bb\u4e0brpm\u5305,\u5403\u529b\u4e0d\u8ba8\u597d<\/span><\/p>\n<p><span style=\"color: #333333;\">2 \u00a0<wbr \/>kernel debuginfo\u5305\u5b89\u88c5<\/span><\/p>\n<p><span style=\"color: #333333;\">\u8fd9\u4e00\u70b9RHEL6 \u8ddf RHEL5\u4e0d\u540c, redhat\u6ca1\u6709\u63d0\u4f9b kernel debuginfo \u5305\u7684ftp\u4e0b\u8f7d(\u4e5f\u53ef\u80fd\u662f\u6211\u6ca1\u6709\u627e\u5230),<\/span><\/p>\n<p><span style=\"color: #333333;\">\u4f30\u8ba1\u53ef\u80fd\u662f\u8981\u6536\u94b1\u4e86,\u7f51\u4e0a\u5927\u90e8\u5206\u90fd\u662fcentos\u6216\u8005\u5176\u4ed6\u6e90\u7801\u7f16\u8bd1\u7684(rpm -qi xxx.rpm \u7684Vendor\u5b57\u6bb5)<\/span><\/p>\n<p><span style=\"color: #333333;\">\u7528 http:\/\/rpm.pbone.net\/ \u641c<\/span><\/p>\n<p><span style=\"color: #333333;\">rpm -ivh kernel-debuginfo-2.6.32-279.el6.x86_64.rpm<\/span><\/p>\n<p><span style=\"color: #333333;\">rpm -ivh kernel-debuginfo-common-x86_64-2.6.32-279.el6.x86_64.rpm<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u00a0\u00a0http:\/\/smilejay.com\/2016\/04\/centos7-kdump-configuration\/ 1. \u5173\u4e8ekdump \u548c crash kdump\u662f\u4e00\u79cdkernel crash dump\u7684\u673a\u5236\uff0c\u5b83\u53ef\u4ee5\u5728\u5185\u6838crash\u65f6\u4fdd\u5b58\u7cfb\u7edf\u7684\u5185\u5b58\u4fe1\u606f\u7528\u4e8e\u540e\u7eed\u7684\u5206\u6790\u3002kdump\u662f\u57fa\u4e8ekexec\u7684\u3002 crash\u662f\u4e00\u4e2a\u7528\u4e8e\u4ea4\u4e92\u5f0f\u5730\u5206\u6790\u6b63\u5728\u8fd0\u884c\u7684Linux\u7cfb\u7edf\u6216\u8005kernel crash\u540e\u7684core dump\u6570\u636e\u7684\u5de5\u5177\u3002 dump\u7684\u5de5\u4f5c\u539f\u7406\u56fe\uff1a 2. \u5728CentOS 7 \u4e2d\u914d\u7f6ekdump \u9700\u8981\u5728kernel\u542f\u52a8\u547d\u4ee4\u884c\u53c2\u6570\u4e2d\u6dfb\u52a0crashkernel\u53c2\u6570\uff0c\u5e76\u542f\u52a8kdump\u670d\u52a1\u3002 \u4e00\u822c\u8bbe\u7f6e\u4e3a crashkernel=auto \u8868\u793a\u6839\u636e\u7cfb\u7edf\u5185\u5b58\u81ea\u52a8reserve\u4e00\u4e9b\u5185\u5b58\u7ed9kernelcrash\u7528\uff0c\u5728x86_64\u7cfb\u7edf\u4e2d\u5185\u5b58\u5927\u4e8e\u7b49\u4e8e2GB\u65f6\u4f1areserve\u5185\u5b58\uff0c\u6700\u5c0f\u4fdd\u7559\u5185\u5b58\u8ba1\u7b97\u65b9\u6cd5\u662f\uff1a160 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=727"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}