{"id":2846,"date":"2016-09-25T19:01:14","date_gmt":"2016-09-25T11:01:14","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2846"},"modified":"2016-09-25T19:01:14","modified_gmt":"2016-09-25T11:01:14","slug":"mysql%e5%a4%8d%e5%88%b6%e4%ba%a7%e7%94%9f%e5%bb%b6%e8%bf%9f%e7%9a%84%e5%8e%9f%e5%9b%a0%e5%8f%8a%e5%ae%9a%e4%bd%8d%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2846.html","title":{"rendered":"MySQL\u590d\u5236\u4ea7\u751f\u5ef6\u8fdf\u7684\u539f\u56e0\u53ca\u5b9a\u4f4d\u65b9\u6cd5"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531\uff1a<\/h5>\n<p>\u4e4b\u524d\u8bb0\u5f55\u4e86\u4e24\u7bc7MySQL\u590d\u5236\u76f8\u5173\u7684\u6587\u7ae0\uff1a\u300c<a href=\"http:\/\/ixyzero.com\/blog\/archives\/2843.html\" target=\"_blank\">MySQL\u4e3b\u4ece\u73af\u5883\u642d\u5efa<\/a>\u300d\u3001\u300c<a href=\"http:\/\/ixyzero.com\/blog\/archives\/2893.html\" target=\"_blank\">MySQL\u4e3b\u4ece\u73af\u5883\u91cd\u5efa<\/a>\u300d\uff0c\u8fd9\u91cc\u518d\u8bb0\u5f55\u4e00\u4e0bMySQL\u590d\u5236\u4ea7\u751f\u5ef6\u8fdf\u7684\u539f\u56e0\u548c\u5b9a\u4f4d\u65b9\u6cd5\uff0c\u65b9\u4fbf\u4ee5\u540e\u6709\u673a\u4f1a\u518d\u6df1\u5165\u7814\u7a76\u4e00\u4e0b\u3002<\/p>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<h6>\u5982\u4f55\u8bc6\u522bMySQL\u590d\u5236\u5b58\u5728\u5ef6\u8fdf\uff1f<\/h6>\n<p>MySQL\u590d\u5236\u548cSlave\u7684\u4e24\u4e2a\u7ebf\u7a0b\u6709\u5173\uff1aIO_THREAD \u548c SQL_THREAD\u3002IO_THREAD \u8fde\u63a5\u5230 Master \u4e0a\u8bfb\u53d6 binlog \u5185\u5bb9\u7684\u53d8\u5316\u5e76\u5c06\u5176\u590d\u5236\u5230Slave\u4e0a\u4e00\u4e2a\u79f0\u4e4b\u4e3a relaylog \u7684\u672c\u5730\u6587\u4ef6\u4e2d\u3002\u53e6\u4e00\u65b9\u9762\uff0cSQL_THREAD \u7ebf\u7a0b\u8bfb\u53d6\u5b58\u50a8\u5728Slave\u672c\u5730\u7684 relaylog \u5e76\u5c06\u5b83\u4eec\u4e2d\u7684\u64cd\u4f5c\u5c3d\u53ef\u80fd\u7684\u5feb\u5728Slave\u4e0a\u6267\u884c\u3002\u6240\u4ee5\u5f53\u51fa\u73b0\u590d\u5236\u5ef6\u8fdf\u65f6\uff0c\u91cd\u8981\u7684\u5224\u65ad\u95ee\u9898\u5230\u5e95\u51fa\u5728Slave\u7684 IO_THREAD \u8fd8\u662f SQL_THREAD \u7ebf\u7a0b\u4e0a\u3002<\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0cIO_THREAD \u7ebf\u7a0b\u4e0d\u4f1a\u5bfc\u81f4\u4e00\u4e2a\u5de8\u5927\u7684\u590d\u5236\u5ef6\u8fdf\uff0c\u56e0\u4e3a\u5b83\u53ea\u662f\u4ece Master \u4e0a\u8bfb\u53d6 binlog\u3002\u7136\u800c\uff0c\u5b83\u53d6\u51b3\u4e8e\u7f51\u7edc\u8fde\u901a\u6027\u3001\u7f51\u7edc\u5ef6\u8fdf\u2026\u2026\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u901f\u5ea6\u6709\u591a\u5feb\uff0c\u5f53\u5e26\u5bbd\u5360\u7528\u6bd4\u8f83\u9ad8\u65f6\uff0cIO_THREAD \u7ebf\u7a0b\u7684\u5ef6\u8fdf\u5c31\u4f1a\u6bd4\u8f83\u5927\u3002\u901a\u5e38\uff0c\u5f53 IO_THREAD \u7ebf\u7a0b\u53ef\u4ee5\u5feb\u901f\u7684\u5c06Master\u4e0a\u7684binlog\u590d\u5236\u5230Slave\u4e0a\u7684relaylog\u65f6\uff0cSlave\u4e0a\u7684IO_THREAD\u7ebf\u7a0b\u5c31\u4e0d\u662f\u5bfc\u81f4\u590d\u5236\u5ef6\u8fdf\u7684\u7f6a\u9b41\u7978\u9996\u3002<\/p>\n<p>\u4ece\u53e6\u5916\u4e00\u4e2a\u89d2\u5ea6\u6765\u770b\uff0cSlave\u4e0a\u7684SQL_THREAD \u7ebf\u7a0b\u662f\u5bfc\u81f4\u590d\u5236\u5ef6\u8fdf\u7684\u4e3b\u8981\u539f\u56e0\uff0c\u53ef\u80fd\u7531\u4e0b\u9762\u4e00\u4e9b\u56e0\u7d20\u5bfc\u81f4\uff1a<\/p>\n<ul>\n<li>\u786c\u4ef6\u6545\u969c(Hardware Faults)<\/li>\n<li>\u914d\u7f6e\u7684\u53d8\u5316(Configuration Changes)<\/li>\n<li>MySQL\u91cd\u542f(MySQL Restart)<\/li>\n<li>\u4ece\u5e93\u89d2\u8272\u7684\u53d8\u5316(Changing Slave Role)<\/li>\n<li>\u590d\u5236\u6d41\u91cf\u7684\u53d8\u5316(Replication Traffic Changes)<\/li>\n<li>\u4ece\u5e93\u8bfb\u6d41\u91cf\u7684\u53d8\u5316(Slave Read Traffic Changes)<\/li>\n<li>IO\u5b50\u7cfb\u7edf\u8d1f\u8f7d\u7684\u53d8\u5316(Side load on IO subsystem)<\/li>\n<li>\u6570\u636e\u5927\u5c0f\u7684\u53d8\u5316(Data Size Changes)<\/li>\n<li>MySQL\u6216OS\u7248\u672c\u7684\u53d8\u5316(MySQL or OS version changes)<\/li>\n<\/ul>\n<p>\u5f53\u300c<code>show slave status\\G<\/code>\u300d\u547d\u4ee4\u7684\u8f93\u51fa\u7ed3\u679c\u4e2d\uff0c Master_Log_File \u548c Relay_Master_Log_File \u53c2\u6570\u503c\u7684\u5185\u5bb9\u76f8\u540c\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u516c\u5f0f\u300cRead_Master_Log_Pos \u2013 Exec_Master_Log_Pos\u300d\u5927\u4f53\u4e0a\u8ba1\u7b97\u51fa SQL_THREAD \u7ebf\u7a0b\u7684\u5ef6\u8fdf\u3002<\/p>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2014\/05\/02\/how-to-identify-and-cure-mysql-replication-slave-lag\/\">\u5982\u4f55\u8bc6\u522b\u548c\u89e3\u51b3MySQL\u4ece\u5e93\u5ef6\u8fdf\u7684\u95ee\u9898<\/a><\/li>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2011\/07\/29\/reasons-for-mysql-replication-lag\/\">MySQL\u4ece\u5e93\u5ef6\u8fdf\u7684\u4e00\u4e9b\u539f\u56e0<\/a><\/li>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2007\/10\/12\/managing-slave-lag-with-mysql-replication\/\">\u5982\u4f55\u5e94\u5bf9MySQL\u4ece\u5e93\u5ef6\u8fdf<\/a><\/li>\n<li><a href=\"http:\/\/imysql.com\/2014\/08\/30\/mysql-faq-howto-monitor-slave-lag.shtml\">MySQL\u590d\u5236\u4e2dslave\u5ef6\u8fdf\u76d1\u63a7<\/a><\/li>\n<li><a href=\"http:\/\/beerpla.net\/2008\/09\/05\/mysql-slave-lag-delay-explained-and-7-ways-to-battle-it\/\">\u5e94\u5bf9MySQL\u4ece\u5e93\u5ef6\u8fdf\u76847\u4e2a\u65b9\u6cd5<\/a><\/li>\n<li><a href=\"http:\/\/dba.stackexchange.com\/questions\/4311\/is-mysql-replication-affected-by-a-high-latency-interconnect\">http:\/\/dba.stackexchange.com\/questions\/4311\/is-mysql-replication-affected-by-a-high-latency-interconnect<\/a><\/li>\n<li><a href=\"http:\/\/serverfault.com\/questions\/30605\/how-fast-is-mysql-replication\">http:\/\/serverfault.com\/questions\/30605\/how-fast-is-mysql-replication<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e4b\u524d\u8bb0\u5f55\u4e86\u4e24\u7bc7MySQL\u590d\u5236\u76f8\u5173\u7684\u6587\u7ae0\uff1a\u300cMySQL\u4e3b\u4ece\u73af\u5883\u642d\u5efa\u300d\u3001\u300cMySQL\u4e3b\u4ece\u73af [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,23],"tags":[659,16],"class_list":["post-2846","post","type-post","status-publish","format-standard","hentry","category-database","category-knowledgebase-2","tag-lag","tag-mysql"],"views":4931,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2846"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2846\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}