{"id":1931,"date":"2020-07-29T21:17:35","date_gmt":"2020-07-29T13:17:35","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1931"},"modified":"2020-07-29T21:17:35","modified_gmt":"2020-07-29T13:17:35","slug":"mysql%e6%80%a7%e8%83%bd%e5%8f%82%e6%95%b0%e8%b0%83%e4%bc%98","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1931","title":{"rendered":"MySQL\u6027\u80fd\u53c2\u6570\u8c03\u4f18"},"content":{"rendered":"<div class=\\\"blog_title\\\">\n<div>\n\u53c2\u6570\u8c03\u4f18\u662fMySQL\u6027\u80fd\u4f18\u5316\u7684\u91cd\u8981\u65b9\u9762\u4e4b\u4e00\uff0c\u901a\u5e38\u53ea\u9700\u8981\u91cd\u70b9\u5173\u6ce8\u51e0\u4e2a\u4e3b\u8981\u7684\u53c2\u6570\uff0c\u5c31\u80fd\u663e\u8457\u5730\u63d0\u9ad8MySQL\u6027\u80fd\u3002\u6839\u636e\u8fd0\u884c\u7684MySQL\u7248\u672c\u7684\u4e0d\u540c\uff0c\u672c\u6587\u4e2d\u4f7f\u7528\u7684\u4e00\u4e9b\u53c2\u6570\u9ed8\u8ba4\u503c\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff0c\u4f46\u662f\u57fa\u672c\u4e0a\u8fd8\u662f\u4e00\u81f4\u7684\u3002\n<\/div>\n<\/div>\n<div class=\\\"blog_content\\\">\n<div class=\\\"blog_detail\\\">\n<h4>\u4e00\u3001\u786c\u4ef6\u76f8\u5173\u7684\u53c2\u6570\u8c03\u4f18<\/h4>\n<p>\u6839\u636eMySQL\u5b9e\u4f8b\u8fd0\u884c\u7684\u786c\u4ef6\u73af\u5883\uff0c\u4e00\u4e9b\u786c\u4ef6\u76f8\u5173\u7684\u53c2\u6570\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4e3b\u8981\u5982\u4e0b\uff1a<\/p>\n<h5>1.1 innodb_buffer_pool_size<\/h5>\n<ul>\n<li>\u8be5\u53c2\u6570\u901a\u5e38\u8bbe\u7f6e\u4e3a\u603b\u5185\u5b58\u5927\u5c0f\u768450%~70%\uff0c\u5145\u5206\u5229\u7528\u5185\u5b58\u7f13\u5b58\uff0c\u51cf\u5c11\u6362\u9875\u5e26\u6765\u7684\u78c1\u76d8\u6027\u80fd\u635f\u8017\u3002<\/li>\n<li>\u8be5\u53c2\u6570\u8bbe\u7f6e\u7684\u5927\u5c0f\u5c3d\u91cf\u4e0d\u8981\u5927\u4e8e\u6570\u636e\u5e93\u7684\u603b\u5927\u5c0f\uff0c\u5426\u5219\u9020\u6210\u5185\u5b58\u6d6a\u8d39\u3002<\/li>\n<li>\u5728MySQL\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u76d1\u63a7buffer pool\u7684\u4f7f\u7528\u7387\uff0c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u8c03\u6574\u3002<\/li>\n<\/ul>\n<h5>1.2 innodb_log_file_size<\/h5>\n<ul>\n<li>\u8be5\u53c2\u6570\u901a\u5e38\u8bbe\u7f6e\u4e3a128M ~ 2G\u4e4b\u95f4\u3002<\/li>\n<li>\u8be5\u53c2\u6570\u5927\u5c0f\u5e94\u5f53\u80fd\u591f\u652f\u6301\u6700\u5c11\u4e00\u4e2a\u5c0f\u65f6\u7684\u65e5\u5fd7\u91cf\uff0c\u4fdd\u8bc1\u5728\u5237\u810f\u9875\u548c\u505a\u68c0\u67e5\u70b9\u64cd\u4f5c\u671f\u95f4\uff0c\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u987a\u5e8f\u5199\u65e5\u5fd7\u3002<\/li>\n<\/ul>\n<h5>1.3 innodb_flush_log_at_trx_commit<\/h5>\n<ul>\n<li>\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a1\uff0c\u4e8b\u52a1\u5b9e\u65f6\u843d\u76d8\uff0c\u4fdd\u8bc1\u6570\u636e\u7684\u6301\u4e45\u6027\uff0c\u4f46\u662f\u5f71\u54cd\u6027\u80fd\u3002<\/li>\n<li>\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a0\u62162\uff0c\u6027\u80fd\u8f83\u9ad8\uff0c\u4f46\u662f\u4e8b\u52a1\u65e0\u6cd5\u5b9e\u65f6\u843d\u76d8\uff0c\u5b58\u5728\u4e22\u5931\u6570\u636e\u7684\u98ce\u9669\u3002<\/li>\n<\/ul>\n<h5>1.4 sync_binlog<\/h5>\n<ul>\n<li>\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a1\uff0cbinlog\u65e5\u5fd7\u5b9e\u65f6\u843d\u76d8\uff0c\u4fdd\u8bc1\u6570\u636e\u7684\u6301\u4e45\u6027\uff0c\u4f46\u662f\u5f71\u54cd\u6027\u80fd\u3002<\/li>\n<li>\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a0\uff0c\u6027\u80fd\u8f83\u9ad8\uff0c\u4f46\u662fbinlog\u65e5\u5fd7\u65e0\u6cd5\u5b9e\u65f6\u843d\u76d8\uff0c\u5b58\u5728\u4e22\u5931\u6570\u636e\u7684\u98ce\u9669\u3002<\/li>\n<\/ul>\n<h5>1.5 innodb_flush_method<\/h5>\n<p>\u5c06\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3aO_DIRECT\u5c06\u907f\u514d\u53cc\u7f13\u51b2\u5e26\u6765\u7684\u6027\u80fd\u635f\u5931\uff0c\u4ecebuffer pool\u76f4\u63a5\u5f80\u78c1\u76d8\u4e0a\u5199\uff0c\u907f\u514d\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u7f13\u51b2\u5e26\u6765\u7684\u6027\u80fd\u635f\u8017\u3002<\/p>\n<h4>\u4e8c\u3001\u53c2\u6570\u4f18\u5316\u6700\u4f73\u5b9e\u8df5<\/h4>\n<h5>2.1 innodb_file_per_table<\/h5>\n<p>innodb_file_per_table\u8bbe\u7f6e\u4e3aON\uff0c\u4e3a\u6bcf\u4e00\u4e2a\u8868\u751f\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u8868\u7a7a\u95f4\u3002<\/p>\n<h5>2.2 innodb_stats_on_metadata<\/h5>\n<p>innodb_stats_on_metadata\u8bbe\u7f6e\u4e3aOFF\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684InnoDB\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0\uff0c\u53ef\u5927\u5927\u63d0\u9ad8\u8bfb\u53d6\u901f\u5ea6\u3002<\/p>\n<h5>2.3 innodb_buffer_pool_instances<\/h5>\n<p>innodb_buffer_pool_instances\u53c2\u6570\uff0c\u4e00\u4e2a\u6bd4\u8f83\u597d\u7684\u8bbe\u7f6e\u503c\u4e3a8\uff0c\u5982\u679cbuffer pool size \u5c0f\u4e8e 1G\uff0c\u5c06\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a1\u3002<\/p>\n<h5>2.4 query_cache_type\u00a0&amp;\u00a0query_cache_size<\/h5>\n<p>\u8fd9\u4e24\u4e2a\u53c2\u6570\u5e94\u5f53\u8bbe\u7f6e\u4e3a0\uff0c\u7981\u7528\u67e5\u8be2\u7f13\u5b58\u3002\u5728MySQL 8.0 \u7248\u672c\uff0c\u67e5\u8be2\u7f13\u5b58\u529f\u80fd\u53ca\u53c2\u6570\u88ab\u6574\u4f53\u79fb\u9664\uff0c\u800c5.7\u53ca\u4ee5\u4e0b\u7248\u672c\uff0c\u5e94\u5f53\u7981\u7528\u67e5\u8be2\u7f13\u5b58\u3002<\/p>\n<h5>2.5 innodb_autoinc_lock_mode<\/h5>\n<p>\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a2\uff08\u4ea4\u9519\u6a21\u5f0f\uff09\u80fd\u591f\u907f\u514dauto-inc\u9501\uff08\u8868\u7ea7\u9501\uff09,\u663e\u8457\u63d0\u9ad8\u6027\u80fd\uff0c\u524d\u63d0binlog\u683c\u5f0f\u4e3aROW\u6216\u8005MIXED\u3002<\/p>\n<h5>2.6 innodb_io_capacity\u00a0&amp;\u00a0innodb_io_capacity_max<\/h5>\n<p>\u5728\u5199\u5165\u5f88\u91cd\u7684\u573a\u666f\u4e0b\uff0c\u8fd9\u4e24\u4e2a\u53c2\u6570\u5c06\u4f1a\u5f71\u54cdMySQL\u7684\u5199\u5165\u6027\u80fd\u3002\u9996\u5148\u9700\u8981\u4e86\u89e3\u78c1\u76d8IO\u7684\u6027\u80fd\uff0c\u5373IOPS\uff0c\u53ef\u4ee5\u5148\u4f7f\u7528sysbench\u6d4b\u8bd5\u78c1\u76d8IO\u6027\u80fd\uff0c\u7136\u540e\u518d\u8c03\u6574innodb_io_capacity\u548cinnodb_io_capacity_max\uff0c\u4ee5\u4fbf\u6700\u5927\u7a0b\u5ea6\u5229\u7528\u78c1\u76d8IO\u7684\u80fd\u529b\u3002\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u6570\u8c03\u4f18\u662fMySQL\u6027\u80fd\u4f18\u5316\u7684\u91cd\u8981\u65b9\u9762\u4e4b\u4e00\uff0c\u901a\u5e38\u53ea\u9700\u8981\u91cd\u70b9\u5173\u6ce8\u51e0\u4e2a\u4e3b\u8981\u7684\u53c2\u6570\uff0c\u5c31\u80fd\u663e\u8457\u5730\u63d0\u9ad8MySQL\u6027\u80fd\u3002\u6839 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1931\"> <span class=\"screen-reader-text\">MySQL\u6027\u80fd\u53c2\u6570\u8c03\u4f18<\/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":"\u53c2\u6570\u8c03\u4f18\u662fMySQL\u6027\u80fd\u4f18\u5316\u7684\u91cd\u8981\u65b9\u9762\u4e4b\u4e00\uff0c\u901a\u5e38\u53ea\u9700\u8981\u91cd\u70b9\u5173\u6ce8\u51e0\u4e2a\u4e3b\u8981\u7684\u53c2\u6570\uff0c\u5c31\u80fd\u663e\u8457\u5730\u63d0\u9ad8MySQL\u6027\u80fd\u3002\u6839&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1931"}],"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=1931"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1931\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1931"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}