{"id":2055,"date":"2020-07-29T23:28:47","date_gmt":"2020-07-29T15:28:47","guid":{"rendered":"http:\/\/39.97.231.10\/?p=2055"},"modified":"2020-07-29T23:28:47","modified_gmt":"2020-07-29T15:28:47","slug":"mysql%e5%8f%82%e6%95%b0%e8%a7%a3%e6%9e%90innodb_max_dirty_pages_pct","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=2055","title":{"rendered":"MySQL\u53c2\u6570\u89e3\u6790innodb_max_dirty_pages_pct"},"content":{"rendered":"<div class=\\\"blog_content\\\">\n<div class=\\\"blog_detail\\\">\n<div>\ninnodb_max_dirty_pages_pct \u662f MySQL InnoDB \u5b58\u50a8\u5f15\u64ce\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u53c2\u6570\uff0c\u7528\u6765\u63a7\u5236buffer pool\u4e2d\u810f\u9875\u7684\u767e\u5206\u6bd4\uff0c\u5f53\u810f\u9875\u6570\u91cf\u5360\u6bd4\u8d85\u8fc7\u8fd9\u4e2a\u53c2\u6570\u8bbe\u7f6e\u7684\u503c\u65f6\uff0cInnoDB\u4f1a\u542f\u52a8\u5237\u810f\u9875\u7684\u64cd\u4f5c\u3002\u8be5\u53c2\u6570\u53ea\u63a7\u5236\u810f\u9875\u767e\u5206\u6bd4\uff0c\u5e76\u4e0d\u4f1a\u5f71\u54cd\u5237\u810f\u9875\u7684\u901f\u5ea6\u3002<br \/>\ninnodb_max_dirty_pages_pct \u53c2\u6570\u53ef\u4ee5\u52a8\u6001\u8c03\u6574\uff0c\u6700\u5c0f\u503c\u4e3a0\uff0c \u6700\u5927\u503c\u4e3a99.99\uff0c\u9ed8\u8ba4\u503c\u4e3a 75\u3002<\/p>\n<h4>innodb_max_dirty_pages_pct\u53c2\u6570\u6e90\u7801\u89e3\u6790<\/h4>\n<p><strong>\u6e90\u7801\u7248\u672c\uff1a5.7.19<\/strong><\/p>\n<h5>\uff081\uff09\u4fdd\u5b58\u810f\u9875\u767e\u5206\u6bd4\u7684\u53d8\u91cf<\/h5>\n<p>\u5728InnoDB\u6e90\u7801\u4e2d\uff0cinnodb_max_dirty_pages_pct\u53c2\u6570\u503c\u4fdd\u5b58\u5728\u53d8\u91cfsrv_max_buf_pool_modified_pct \u91cc\u9762\uff0c\u8fd9\u662f\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u521d\u59cb\u503c\u4e3a 75.0\uff0c\u5982\u4e0b\uff1a<br \/>\ndouble\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0srv_max_buf_pool_modified_pct\u00a0= 75.0;<\/p>\n<h5>\uff082\uff09\u5237\u810f\u9875\u7684\u7ebf\u7a0b<\/h5>\n<p>InnoDB\u5237\u810f\u9875\u4e3b\u8981\u901a\u8fc7\u4e24\u7c7b\u7ebf\u7a0b\u6765\u5b9e\u73b0\uff0c\u8fd9\u4e24\u7c7b\u7ebf\u7a0b\u5206\u522b\u662f\uff1a<\/p>\n<ul>\n<li>buf_flush_page_cleaner_coordinator\uff0c\u534f\u8c03\u7ebf\u7a0b<\/li>\n<li>buf_flush_page_cleaner_worker\uff0c\u5de5\u4f5c\u7ebf\u7a0b<\/li>\n<\/ul>\n<ol>\n<li>\u534f\u8c03\u7ebf\u7a0b\u4e2d\u6709\u4e00\u4e2awhile\u5faa\u73af\uff0c\u6bcf1\u79d2\u6267\u884c\u4e00\u6b21\u810f\u9875\u767e\u5206\u6bd4\u7684\u68c0\u67e5\uff0c\u5f53\u810f\u9875\u767e\u5206\u6bd4\u8d85\u8fc7\u9608\u503c\uff0c\u89e6\u53d1\u4e8b\u4ef6\uff0c\u5524\u9192\u5de5\u4f5c\u7ebf\u7a0b\uff0c\u6267\u884c\u5237\u810f\u9875\u7684\u64cd\u4f5c\u3002<br \/>\nos_event_set(page_cleaner-&gt;is_requested);<\/li>\n<li>\u5de5\u4f5c\u7ebf\u7a0b\u4e2d\u6709\u4e00\u4e2awhile\u5faa\u73af\uff0c\u4e3b\u8981\u5728\u7b49\u5f85\u5237\u810f\u9875\u7684\u4e8b\u4ef6\uff0c\u5982\u679c\u4e8b\u4ef6\u88ab\u89e6\u53d1\uff0c\u5de5\u4f5c\u7ebf\u7a0b\u5c31\u4f1a\u6267\u884c\u5237\u810f\u9875\u7684\u64cd\u4f5c\uff0c\u5237\u5b8c\u810f\u9875\u4e4b\u540e\uff0c\u7ee7\u7eed\u7b49\u5f85\u4e8b\u4ef6\uff0c\u7b49\u5f85\u4e0b\u4e00\u6b21\u88ab\u5524\u9192\u3002<br \/>\nos_event_wait(page_cleaner-&gt;is_requested);<\/li>\n<\/ol>\n<h5>\uff083\uff09\u51fd\u6570\u8c03\u7528\u5173\u7cfb<\/h5>\n<p>\u534f\u8c03\u7ebf\u7a0b\u901a\u8fc7\u8c03\u7528\u4e00\u7cfb\u5217\u7684\u51fd\u6570\uff0c\u6765\u83b7\u53d6\u810f\u9875\u767e\u5206\u6bd4\uff0c\u5224\u65ad\u662f\u5426\u9700\u8981\u5237\u810f\u9875\uff0c\u51fd\u6570\u8c03\u7528\u5173\u7cfb\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>buf_flush_page_cleaner_coordinator()\n<ul>\n<li>page_cleaner_flush_pages_recommendation(\uff09\n<ul>\n<li>af_get_pct_for_dirty()<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\uff084\uff09af_get_pct_for_dirty()\u51fd\u6570\u7684\u5b9e\u73b0<\/h5>\n<p>af_get_pct_for_dirty() \u51fd\u6570\u8c03\u7528buf_get_modified_ratio_pct()\u83b7\u53d6\u5df2\u4fee\u6539\u9875\u7684\u767e\u5206\u6bd4\uff0c\u7136\u540e\u4e0esrv_max_dirty_pages_pct_lwm\u53casrv_max_buf_pool_modified_pct\u53d8\u91cf\u8fdb\u884c\u6bd4\u8f83\uff0c\u6700\u7ec8\u8fd4\u56de\u4e00\u4e2a0~100\u7684\u503c\uff0c\u7ed9\u4e0a\u5c42\u8c03\u7528\u51fd\u6570\uff0c\u6765\u51b3\u5b9a\u662f\u5426\u9700\u8981\u5237\u810f\u9875\u3002af_get_pct_for_dirty()\u51fd\u6570\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n<pre><code>static\nulint\naf_get_pct_for_dirty()\n\/*==================*\/\n{\n\tdouble\tdirty_pct = buf_get_modified_ratio_pct();\n\tif (dirty_pct == 0.0) {\n\t\t\/* No pages modified *\/\n\t\treturn(0);\n\t}\n\tut_a(srv_max_dirty_pages_pct_lwm\n\t     &lt;= srv_max_buf_pool_modified_pct);\n\tif (srv_max_dirty_pages_pct_lwm == 0) {\n\t\t\/* The user has not set the option to preflush dirty\n\t\tpages as we approach the high water mark. *\/\n\t\tif (dirty_pct &gt;= srv_max_buf_pool_modified_pct) {\n\t\t\t\/* We have crossed the high water mark of dirty\n\t\t\tpages In this case we start flushing at 100% of\n\t\t\tinnodb_io_capacity. *\/\n\t\t\treturn(100);\n\t\t}\n\t} else if (dirty_pct &gt;= srv_max_dirty_pages_pct_lwm) {\n\t\t\/* We should start flushing pages gradually. *\/\n\t\treturn(static_cast&lt;ulint&gt;((dirty_pct * 100)\n\t\t       \/ (srv_max_buf_pool_modified_pct + 1)));\n\t}\n\treturn(0);\n}\n<\/code><\/pre>\n<h5>\uff085\uff09\u5176\u4ed6\u89e6\u53d1\u5237\u810f\u9875\u7684\u573a\u666f<\/h5>\n<p>\u9664\u4e86\u810f\u9875\u767e\u5206\u6bd4\u8fbe\u5230\u9608\u503cinnodb_max_dirty_pages_pct\u89e6\u53d1\u5237\u810f\u9875\u4ee5\u5916\uff0c\u8fd8\u6709\u5f88\u591a\u6761\u4ef6\uff0c\u4e5f\u4f1a\u89e6\u53d1\u5237\u810f\u9875\uff0c\u4e3b\u8981\u5305\u62ec\uff1a<\/p>\n<ol>\n<li>REDO\u65e5\u5fd7\u5feb\u6ee1\u7684\u65f6\u5019\u3002<\/li>\n<li>\u4e3a\u4e86\u4fdd\u8bc1MySQL\u4e2d\u7684\u7a7a\u95f2\u9875\u9762\u7684\u6570\u91cf\uff0c\u4f1a\u4eceLRU \u94fe\u8868\u5c3e\u90e8\u6dd8\u6c70\u4e00\u90e8\u5206\u9875\u9762\u4f5c\u4e3a\u7a7a\u95f2\u9875\u3002\u5982\u679c\u5bf9\u5e94\u7684\u9875\u9762\u662f\u810f\u9875\u7684\u8bdd\uff0c\u5c31\u9700\u8981\u5148\u5c06\u9875\u9762\u5237\u5230\u78c1\u76d8\u3002<\/li>\n<li>MySQL\u5b9e\u4f8b\u6b63\u5e38\u5173\u95ed\u65f6\u5019\u3002<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>innodb_max_dirty_pages_pct \u662f MySQL InnoDB \u5b58\u50a8\u5f15\u64ce\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u53c2\u6570 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=2055\"> <span class=\"screen-reader-text\">MySQL\u53c2\u6570\u89e3\u6790innodb_max_dirty_pages_pct<\/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":"innodb_max_dirty_pages_pct \u662f MySQL InnoDB \u5b58\u50a8\u5f15\u64ce\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u53c2\u6570&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2055"}],"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=2055"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2055\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2055"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}