
{"id":351,"date":"2021-09-01T13:06:17","date_gmt":"2021-09-01T05:06:17","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=351"},"modified":"2023-10-20T20:57:44","modified_gmt":"2023-10-20T12:57:44","slug":"%e6%a3%80%e6%9f%a5mariadb%e4%b8%bb%e4%bb%8e%e5%ba%93%e6%98%af%e5%90%a6%e4%b8%80%e8%87%b4","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=351","title":{"rendered":"\u68c0\u67e5MariaDB\u4e3b\u4ece\u5e93\u662f\u5426\u4e00\u81f4"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-69e1c1c198ae1\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e1c1c198ae1\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=351\/#1_%E6%A3%80%E6%9F%A5%E4%BB%8E%E5%BA%93%E4%B8%8ASlave_IO_Running%E4%B8%8ESlave_SQL_Running\" >1. \u68c0\u67e5\u4ece\u5e93\u4e0aSlave_IO_Running\u4e0eSlave_SQL_Running<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=351\/#2_%E6%A3%80%E6%9F%A5%E4%BB%8E%E5%BA%93%E4%B8%8A%E7%9A%84Master_Log_File%E4%B8%8EMaster_Log_File\" >2. \u68c0\u67e5\u4ece\u5e93\u4e0a\u7684Master_Log_File\u4e0eMaster_Log_File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/dba.qishuo.xin\/?p=351\/#3_%E6%A3%80%E6%9F%A5%E4%BB%8E%E5%BA%93%E4%B8%8A%E7%9A%84Read_Master_Log_Pos%E5%92%8CExec_Master_Log_Pos\" >3. \u68c0\u67e5\u4ece\u5e93\u4e0a\u7684Read_Master_Log_Pos\u548cExec_Master_Log_Pos<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/dba.qishuo.xin\/?p=351\/#4_%E9%99%84%E5%BD%95\" >4. \u9644\u5f55<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong><span style='color:red'> MariaDB\u4e3b\u4ece\u5e93\u4e00\u81f4\u6027\u7684\u68c0\u67e5\u4e3b\u8981\u6839\u636e\u4ece\u5e93\u4e0a\u7684io\u8fdb\u7a0b(Slave_IO_Running)\u548csql\u8fdb\u7a0b(Slave_SQL_Running)\u662f\u5426\u90fd\u4e3ayes\uff0csql\u8fdb\u7a0b\u662f\u5426\u51fa\u73b0\u5ef6\u8fdf(Seconds_Behind_Master)\u6765\u5224\u65ad\u3002<\/span><\/strong><br \/>\n\u540c\u65f6\u68c0\u67e5\u4ece\u5e93\u4e0aio\u8bfb\u53d6\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6587\u4ef6\u4e0e\u4f4d\u7f6e\u662f\u5426\u548c\u4e3b\u5e93\u5b8c\u5168\u4e00\u81f4(\u5982\u679cio\u8fdb\u7a0b\u4e3ayes\u7684\u8bdd,\u5f88\u5c11\u4f1a\u4e0d\u4e00\u81f4)\u3002\u4f46\u662fposition\u4f4d\u7f6e\u53d8\u5316\u5f88\u5feb,\u8fdc\u7a0b\u8fde\u63a5\u4e3b\u5e93\u548c\u4ece\u5e93\u8fdb\u884c\u6bd4\u8f83\u7684\u529f\u592b,\u8bf4\u4e0d\u5b9aposition\u5df2\u7ecf\u53d8\u5316\u4e86\u3002\uff08\u5373\u68c0\u67e5 <span style='color:blue'> <code>Master_Log_File<\/code> \u4e0e <code>Relay_Master_Log_File<\/code> \u662f\u5426\u4e00\u81f4\u3002<\/span> \u4ee5\u53ca  <span style='color:blue'> <code>Read_Master_Log_Pos <\/code> \u4e0e <code>Exec_Master_Log_Pos<\/code> \u662f\u5426\u4e00\u81f4\u3002 <\/span><\/p>\n<h4><span class=\"ez-toc-section\" id=\"1_%E6%A3%80%E6%9F%A5%E4%BB%8E%E5%BA%93%E4%B8%8ASlave_IO_Running%E4%B8%8ESlave_SQL_Running\"><\/span>1. \u68c0\u67e5\u4ece\u5e93\u4e0aSlave_IO_Running\u4e0eSlave_SQL_Running<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u8fdb\u5165mysql\u7684\u547d\u4ee4\u884c\u72b6\u6001\uff0c\u6267\u884c<code>show slave status\\G<\/code>\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-sql\">MariaDB [(none)]&gt;\nshow slave status\\G<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/09\/wp_editor_md_4e4f5167ff8d88fcbee3c8287c5713fa.jpg\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/09\/wp_editor_md_4e4f5167ff8d88fcbee3c8287c5713fa.jpg\" alt=\"\" \/><\/a><\/p>\n<p><strong>Slave_IO\u7ebf\u7a0b<\/strong>\uff1a\u8d1f\u8d23\u628a\u4e3b\u5e93\u7684bin\u65e5\u5fd7\uff08Master_Log\uff09\u5185\u5bb9\uff0c\u6284\u5199\u5230\u4ece\u5e93\u7684\u4e2d\u7ee7\u65e5\u5fd7\u4e0a\uff08Relay_Log\uff09\u3002Slave_IO\u7ebf\u7a0b\u6bd4\u8f83\u7b80\u5355\uff0c\u4e00\u822c\u4e0d\u5bb9\u6613\u51fa\u9519\uff0c\u5982\u679cSlave_IO_Running\u663e\u793a\u4e3aNo\uff0c\u591a\u4e3a\u7f51\u7edc\u8fde\u63a5\u4e0d\u4e0a\uff0c\u6743\u9650\u4e0d\u591f\u7b49\u73af\u5883\u95ee\u9898\uff1b<br \/>\n<strong>Slave_SQL\u7ebf\u7a0b<\/strong>\uff1a\u8d1f\u8d23\u628a\u4e2d\u7ee7\u65e5\u5fd7\u4e0a\u7684\u8bed\u53e5\u5728\u4ece\u5e93\u4e0a\u6267\u884c\u4e00\u904d\uff0c\u76f8\u5bf9\u4e8eSlave_IO\uff0cSlave_SQL\u7ebf\u7a0b\u662f\u6bd4\u8f83\u5bb9\u6613\u51fa\u9519\u7684<br \/>\n\u793a\u4f8b\uff1a<\/p>\n<ol>\n<li>\u624b\u52a8\u5728\u4ece\u5e93\u4e2d\u63d2\u5165\u4e00\u6761\u6570\u636e\uff0c\u9020\u6210\u4e3b\u4ece\u4e0d\u4e00\u81f4\uff0c\u6b64\u65f6\u4e24\u4e2a\u7ebf\u7a0b\u7684\u72b6\u6001\u4f9d\u65e7\u662f\u6b63\u5e38\u7684\uff1b<\/li>\n<li>\u7136\u540e\u5728\u4e3b\u5e93\u4e5f\u63d2\u5165\u4e00\u6761\u540c\u6837\u7684\u6570\u636e\uff0c\u901a\u77e5\u4ece\u5e93\u505a\u76f8\u540c\u64cd\u4f5c\uff0c\u4ece\u5e93\u4f1a\u51fa\u73b0\u4e3b\u952e\u91cd\u590d\u7684\u9519\u8bef\uff0c\u8fd9\u65f6\u5019Slave_SQL_Running\u7684\u72b6\u6001\u4f1a\u53d8\u4e3aNo\uff0c\u800cLast_SQL_Error\u548cLast_SQL_Error_Timestamp\u4f1a\u8bb0\u5f55\u9519\u8bef\u7684\u539f\u56e0\u548c\u53d1\u751f\u65f6\u95f4\uff1b<\/li>\n<li>Slave_SQL\u7ebf\u7a0b\u4f1a\u505c\u6b62\u540e\u7eed\u7684SQL\u8bed\u53e5\u6267\u884c\uff0c\u56e0\u4e3a\u5b83\u610f\u8bc6\u5230\u5f80\u540e\u6267\u884c\u4f1a\u5bfc\u81f4\u9519\u8bef\u4fee\u590d\u7684\u96be\u5ea6\u589e\u52a0\uff1b<\/li>\n<li>\u4f46Slave_IO\u7ebf\u7a0b\u4f1a\u7ee7\u7eed\u6284log\u7684\u5de5\u4f5c\uff0c\u6240\u4ee5\u4e2d\u7ee7log\u4f9d\u7136\u662f\u6700\u65b0\u7684\uff1b<\/li>\n<li>\u8fd9\u65f6\u5019Master_Log_File: mysql-bin.000145\u548cRelay_Master_Log_File: mysql-bin.000144\u4e4b\u95f4\u5c31\u4ea7\u751f\u4e86\u504f\u5dee\u3002<\/li>\n<\/ol>\n<p>\u5f53\u9519\u8bef\u4fee\u590d\u540e\uff0c\u53ea\u9700\u7528<code>stop slave<\/code>\u548c<code>start slave<\/code>\u91cd\u542f\u4e0b\u540c\u6b65\uff0cSlave_SQL\u7ebf\u7a0b\u4f1a\u91cd\u65b0\u7684\u5c1d\u8bd5\u5de5\u4f5c\uff0c\u5982\u679c\u6ca1\u6709\u95ee\u9898\uff0c\u90a3\u4e48Slave_SQL\u7684\u72b6\u6001\u4f1a\u53d8\u56deYes\uff08\u4f46\u6b64\u65f6\u4e3b\u4ece\u5e76\u6ca1\u6709\u5b8c\u5168\u540c\u6b65\uff0c\u9700\u8981\u4e00\u70b9\u65f6\u95f4\uff09\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"2_%E6%A3%80%E6%9F%A5%E4%BB%8E%E5%BA%93%E4%B8%8A%E7%9A%84Master_Log_File%E4%B8%8EMaster_Log_File\"><\/span>2. \u68c0\u67e5\u4ece\u5e93\u4e0a\u7684Master_Log_File\u4e0eMaster_Log_File<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u8fdb\u5165mysql\u7684\u547d\u4ee4\u884c\u72b6\u6001\uff0c\u6267\u884c<code>show slave status\\G<\/code>\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-sql\">MariaDB [(none)]&gt;\nshow slave status\\G<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/09\/wp_editor_md_e9352d05b76bc1a466ebf62d98b91c5d.jpg\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/09\/wp_editor_md_e9352d05b76bc1a466ebf62d98b91c5d.jpg\" alt=\"\" \/><\/a><\/p>\n<p><strong>Master_Log_File\u548cRelay_Master_Log_File\u6240\u6307\u5411\u7684\u6587\u4ef6\u5fc5\u987b\u4e00\u81f4<\/strong><\/p>\n<h4><span class=\"ez-toc-section\" id=\"3_%E6%A3%80%E6%9F%A5%E4%BB%8E%E5%BA%93%E4%B8%8A%E7%9A%84Read_Master_Log_Pos%E5%92%8CExec_Master_Log_Pos\"><\/span>3. \u68c0\u67e5\u4ece\u5e93\u4e0a\u7684Read_Master_Log_Pos\u548cExec_Master_Log_Pos<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u8fdb\u5165mysql\u7684\u547d\u4ee4\u884c\u72b6\u6001\uff0c\u6267\u884c<code>show slave status\\G<\/code>\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-sql\">MariaDB [(none)]&gt;\nshow slave status\\G<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/09\/wp_editor_md_e959ed449d5d60e75bf2dc96e351f2b3.jpg\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/09\/wp_editor_md_e959ed449d5d60e75bf2dc96e351f2b3.jpg\" alt=\"\" \/><\/a><\/p>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>shell\u547d\u4ee4<\/code> \u6765\u83b7\u53d6\u8fdc\u7a0b <code>Read_Master_Log_Pos<\/code> \u7684\u503c<\/p>\n<pre><code class=\"language-shell\">mysql -h172.16.5.70 -P3306 -uroot -phzxy00yz -e &#039;show master status \\G&#039; |awk &#039;NR==3{print $2}&#039;\n\u6216\uff1a\n mysql -h172.16.5.70 -P3306 -uroot -phzzxy00yz -e &#039;show master status \\G&#039; |grep -w &quot;Position:&quot;<\/code><\/pre>\n<p>\u4f7f\u7528 <code>shell\u547d\u4ee4<\/code> \u6765\u83b7\u53d6\u672c\u5730 <code>Exec_Master_Log_Pos<\/code> \u7684\u503c<\/p>\n<pre><code class=\"language-shell\">mysql -e &#039;show slave status \\G&#039; |awk &#039;NR==23{print $2}&#039;\n\u6216\uff1a\nmysql -e &#039;show slave status \\G&#039; |grep -w &quot;Exec_Master_Log_Pos:&quot;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"4_%E9%99%84%E5%BD%95\"><\/span>4. \u9644\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>1) The position, ON THE MASTER, from which the I\/O thread is reading: <strong>Master_Log_File\/Read_Master_Log_Pos.<\/strong><\/p>\n<p><strong><span style='color:red'>\u76f8\u5bf9\u4e8e\u4e3b\u5e93,\u662f\u4ece\u5e93\u8bfb\u53d6\u4e3b\u5e93\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u4f4d\u7f6e,\u662fIO\u7ebf\u7a0b\u3002\u5373io_thread\u8bfb\u53d6\u4e3b\u5e93master_log_file\u4e0emaster_log_pos<\/span><\/strong><\/p>\n<p>2) The position, ON THE MASTER, at which the SQL thread is executing: <strong>Relay_Master_Log_File\/Exec_Master_Log_Pos<\/strong><\/p>\n<p><strong><span style='color:red'>\u76f8\u5bf9\u4e8e\u4e3b\u5e93,\u662f\u4ece\u5e93\u7684sql\u7ebf\u7a0b\u6267\u884c\u5230\u7684\u4f4d\u7f6e\uff0c\u662fsql\u7ebf\u7a0b\u3002\u5373sql_thread\u6267\u884c\u4e3b\u5e93\u7684master_log_file\u548cmaster_log_pos<\/span><\/strong><\/p>\n<p>3) The position, IN THE RELAY LOGS, at which the SQL thread is executing:Relay_Log_File\/Relay_Log_Pos<br \/>\n<span style='color:red'>\u76f8\u5bf9\u4e8e\u4ece\u5e93,\u662f\u4ece\u5e93\u7684sql\u7ebf\u7a0b\u6267\u884c\u5230\u7684\u4f4d\u7f6e\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MariaDB\u4e3b\u4ece\u5e93\u4e00\u81f4\u6027\u7684\u68c0\u67e5\u4e3b\u8981\u6839\u636e\u4ece\u5e93\u4e0a\u7684i&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,3],"tags":[12,46],"class_list":["post-351","post","type-post","status-publish","format-standard","hentry","category-mariadb","category-mariadbmysql","tag-mariadb","tag-46"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=351"}],"version-history":[{"count":12,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/351\/revisions"}],"predecessor-version":[{"id":3424,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/351\/revisions\/3424"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}