{"id":2049,"date":"2020-07-29T23:27:11","date_gmt":"2020-07-29T15:27:11","guid":{"rendered":"http:\/\/39.97.231.10\/?p=2049"},"modified":"2020-07-29T23:27:11","modified_gmt":"2020-07-29T15:27:11","slug":"mysql%e9%85%8d%e7%bd%ae%e5%8f%82%e6%95%b0core-file","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=2049","title":{"rendered":"MySQL\u914d\u7f6e\u53c2\u6570core-file"},"content":{"rendered":"<div>\n<div>\n1. MySQL core-file \u53c2\u6570\n<\/div>\n<\/div>\n<div>\n<div>\n<div><\/div>\n<div>Linux\u73af\u5883\u4e0b\uff0c\u8fdb\u7a0b\u5d29\u6e83\u751f\u6210core\u6587\u4ef6\u4ee5\u4fbf\u4e8e\u7a0b\u5e8f\u8c03\u8bd5\u548c\u95ee\u9898\u6392\u67e5\u3002\u8fdb\u7a0b\u5728\u542f\u52a8\u524d\uff0c\u8bbe\u7f6ecore file size \u5927\u4e8e0\uff0c\u8fdb\u7a0b\u5d29\u6e83\u901a\u5e38\u5c31\u4f1a\u751f\u6210core file dump\u6587\u4ef6\u3002MySQL\u5728\u7cfb\u7edf\u63d0\u4f9b\u7684core file\u751f\u6210\u673a\u5236\u4e4b\u5916\uff0c\u989d\u5916\u6dfb\u52a0\u4e86\u4e00\u4e2a\u53c2\u6570&#8211;core-file\uff0c\u6765\u63a7\u5236\u662f\u5426\u751f\u6210core\u6587\u4ef6\u3002<\/div>\n<div><\/div>\n<div>\n<div>\n<div>\/\/ mysqld.cc<\/div>\n<div>{\\&#8221;core-file\\&#8221;,\u00a0OPT_WANT_CORE, \\&#8221;Write core on errors.\\&#8221;, 0, 0, 0, GET_NO_ARG,NO_ARG, 0, 0, 0, 0, 0, 0},<\/div>\n<div><\/div>\n<div>&#8230;<\/div>\n<div><\/div>\n<div>case (int) OPT_WANT_CORE:<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0test_flags |= TEST_CORE_ON_SIGNAL;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0break;<\/div>\n<div><\/div>\n<div>&#8230;<\/div>\n<div><\/div>\n<div>\/\/ my_init_signals()<\/div>\n<div>if (test_flags &amp; TEST_CORE_ON_SIGNAL)<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ Change limits so that we will get a core file.<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0struct rlimit rl;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rl.rlim_cur= rl.rlim_max= RLIM_INFINITY;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (setrlimit(RLIMIT_CORE, &amp;rl))<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sql_print_warning(\\&#8221;setrlimit could not change the size of core\u00a0\u00a0files to\\&#8221;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\\&#8221; \\&#8217;infinity\\&#8217;;\u00a0\u00a0We may not be able to generate a\\&#8221;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\\&#8221; core file on signals\\&#8221;);<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0}<\/div>\n<\/div>\n<\/div>\n<div><\/div>\n<div>\u4ee3\u7801\u7248\u672c\uff1a5.7.19<\/div>\n<div><\/div>\n<div>\u4ece\u4ee5\u4e0a\u4ee3\u7801\u53ef\u4ee5\u770b\u51fa\uff0c\u542f\u52a8MySQL\u8fdb\u7a0b\u65f6\uff0c\u52a0\u4e0a&#8211;core-file\u53c2\u6570\uff0c\u5373\u4f7flinux\u7cfb\u7edf\u6ca1\u6709\u914d\u7f6e\u751f\u6210core file\uff0cMySQL\u4e5f\u80fd\u901a\u8fc7\u81ea\u5df1\u5728\u4ee3\u7801\u4e2d\u8c03\u7528\u7cfb\u7edf\u51fd\u6570\u6765\u8ba9\u81ea\u5df1\u8fdb\u7a0b\u5728\u5d29\u6e83\u65f6\u751f\u6210core file\u3002<\/div>\n<div><\/div>\n<div>2. core\u00a0file \u64cd\u4f5c\u7cfb\u7edf\u76f8\u5173\u53c2\u6570\u8bbe\u7f6e<\/div>\n<div><\/div>\n<div>\n<div>echo 2 &gt;\/proc\/sys\/fs\/suid_dumpable<\/div>\n<div>chmod 0777 \/mysql\/crash<\/div>\n<div>echo \/mysql\/crash\/core.%e.%t.%p &gt; \/proc\/sys\/kernel\/core_pattern<\/div>\n<div>echo 1 &gt;\/proc\/sys\/kernel\/core_uses_pid<\/div>\n<\/div>\n<div><\/div>\n<div>\/proc\/sys\/fs\/suid_dumpable \u53d6\u503c\u4e3a0\uff0c1\uff0c2\uff0c\u5177\u4f53\u610f\u4e49\u5982\u4e0b\uff1a<\/div>\n<ul>\n<li>\n<div>0 \u8868\u660e\u8c03\u7528 seteuid\u548c setgid \u6539\u53d8\u7528\u6237\u6216\u7ec4\u7684\u8fdb\u7a0b\uff0c\u5c06\u4e0d\u80fd\u4ea7\u751fcore\u6587\u4ef6<\/div>\n<\/li>\n<li>\n<div>1 \u8868\u660edebug\u6a21\u5f0f\uff0c\u4efb\u4f55\u8fdb\u7a0b\u90fd\u53ef\u4ee5\u4ea7\u751fcore\u6587\u4ef6<\/div>\n<\/li>\n<li>\n<div>2 \u8868\u660e\u751f\u6210\u7684core\u6587\u4ef6\u53ea\u6709root\u7528\u6237\u53ef\u8bfb\uff0c\u66f4\u52a0\u5b89\u5168\u5730\u4fdd\u62a4\u5185\u5b58\u6570\u636e<\/div>\n<\/li>\n<\/ul>\n<div><\/div>\n<div>\/proc\/sys\/kernel\/core_pattern\u00a0\u8bbe\u7f6e\u7684core\u6587\u4ef6\u5b58\u653e\u76ee\u5f55\u548ccore\u6587\u4ef6\u540d\u79f0\uff0c\u6ce8\u610f\u78c1\u76d8\u7a7a\u95f4\u8981\u8db3\u591f\u5b58\u50a8core file\u3002<\/div>\n<div><\/div>\n<div>\/proc\/sys\/kernel\/core_uses_pid\u00a0\u63a7\u5236core\u6587\u4ef6\u6269\u5c55\u540d\u662f\u5426\u5e26\u4e2d\u8fdb\u7a0bid\u3002<\/div>\n<div><\/div>\n<div><\/div>\n<div>3. \u6a21\u62dfMySQL\u5d29\u6e83\uff0c\u751f\u6210core\u6587\u4ef6<\/div>\n<div><\/div>\n<div>\u6d4b\u8bd5\u5f53mysqld\u8fdb\u7a0b\u5d29\u6e83\u65f6\uff0c\u662f\u5426\u4f1a\u4ea7\u751fcore file\uff1a<\/div>\n<div><\/div>\n<div>kill -SEGV mysqld\u8fdb\u7a0b\u53f7<\/div>\n<div><\/div>\n<div>4. gdb\u8c03\u8bd5core\u6587\u4ef6<\/div>\n<div><\/div>\n<div>gdb\u8c03\u8bd5core\u6587\u4ef6\uff1a<\/div>\n<div><\/div>\n<div>gdb \/usr\/local\/mysql\/bin\/mysqld core.mysqld.1573578046.1207<\/div>\n<div><\/div>\n<div>\/usr\/local\/mysql\/bin\/mysqld\u00a0\u4e3aMySQL\u8fdb\u7a0b\u8def\u5f84\u3002<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. MySQL core-file \u53c2\u6570 Linux\u73af\u5883\u4e0b\uff0c\u8fdb\u7a0b\u5d29\u6e83\u751f\u6210core\u6587\u4ef6\u4ee5\u4fbf\u4e8e\u7a0b\u5e8f\u8c03\u8bd5\u548c\u95ee\u9898\u6392\u67e5 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=2049\"> <span class=\"screen-reader-text\">MySQL\u914d\u7f6e\u53c2\u6570core-file<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","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":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"1. MySQL core-file \u53c2\u6570 Linux\u73af\u5883\u4e0b\uff0c\u8fdb\u7a0b\u5d29\u6e83\u751f\u6210core\u6587\u4ef6\u4ee5\u4fbf\u4e8e\u7a0b\u5e8f\u8c03\u8bd5\u548c\u95ee\u9898\u6392\u67e5&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2049"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2049"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2049\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2049"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}