{"id":278,"date":"2026-02-03T10:33:38","date_gmt":"2026-02-03T02:33:38","guid":{"rendered":"http:\/\/47.100.165.17\/wordpress\/?p=278"},"modified":"2026-03-02T22:35:42","modified_gmt":"2026-03-02T14:35:42","slug":"%e3%80%90mysql%e3%80%91binlog-%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97%e4%b8%8e%e6%a0%b8%e5%bf%83%e4%bd%9c%e7%94%a8%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/yunyanglib.cn\/?p=278","title":{"rendered":"\u3010MySQL\u3011Binlog \u914d\u7f6e\u6307\u5357\u4e0e\u6838\u5fc3\u4f5c\u7528\u89e3\u6790"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\" id=\"u1b47593a\">\u4f5c\u4e3a MySQL \u8de8\u5b58\u50a8\u5f15\u64ce\u7684\u6838\u5fc3\u65e5\u5fd7\u7ec4\u4ef6\uff0cBinlog\uff08\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff09\u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u4e2d\u6240\u6709\u6570\u636e\u4fee\u6539\u64cd\u4f5c\uff0c\u662f\u4e3b\u4ece\u590d\u5236\u3001\u6570\u636e\u6062\u590d\u3001\u8de8\u5e93\u8fc1\u79fb\u7b49\u573a\u666f\u7684\u5173\u952e\u652f\u6491\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u62c6\u89e3 Binlog \u7684\u914d\u7f6e\u6d41\u7a0b\u4e0e\u4e09\u5927\u6838\u5fc3\u4f5c\u7528\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u638c\u63e1\u8fd9\u4e00\u5fc5\u5907\u6280\u80fd\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"nv0Mg\">\u4e00\u3001Binlog \u6838\u5fc3\u914d\u7f6e\u64cd\u4f5c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"dntCA\">1. \u5f00\u542f Binlog<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"u08a2d822\">Binlog \u9ed8\u8ba4\u672a\u5f00\u542f\uff0c\u9700\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u624b\u52a8\u542f\u7528\uff0c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre id=\"fnG56\" class=\"wp-block-code\"><code># 1. \u7f16\u8f91MySQL\u914d\u7f6e\u6587\u4ef6\uff08\u8def\u5f84\u9700\u6839\u636e\u5b9e\u9645\u90e8\u7f72\u8c03\u6574\uff09\nvim \/data\/mysql\/conf\/my.cnf\n\n# 2. \u5728&#91;mysqld]\u8282\u70b9\u4e0b\u6dfb\u52a0\u914d\u7f6e\uff0c\u6307\u5b9a\u65e5\u5fd7\u5b58\u50a8\u8def\u5f84\u4e0e\u524d\u7f00\nlog-bin = \/data\/mysql\/binlog\/mysql-bin\n\n# 3. \u91cd\u542fMySQL\u670d\u52a1\u4f7f\u914d\u7f6e\u751f\u6548\n\/etc\/init.d\/mysql.server restart<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"tLdCX\">2. \u9a8c\u8bc1 Binlog \u72b6\u6001<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"u7dba8fbc\">\u914d\u7f6e\u540e\u9700\u786e\u8ba4\u662f\u5426\u542f\u7528\u6210\u529f\uff0c\u6267\u884c\u4ee5\u4e0b SQL \u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre id=\"ZXJbz\" class=\"wp-block-code\"><code>show variables like '%log_bin%';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"u323aa1e1\">\u82e5\u7ed3\u679c\u4e2d<code>log_bin<\/code>\u5b57\u6bb5\u503c\u4e3a<code>ON<\/code>\uff0c\u5219\u8868\u793a Binlog \u5df2\u6210\u529f\u542f\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"xUiQh\">3. \u5173\u95ed Binlog<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"u99f31013\">\u6839\u636e\u573a\u666f\u9700\u6c42\uff0c\u5173\u95ed Binlog \u65b9\u5f0f\u5206\u4e3a\u300c\u5168\u5c40\u5173\u95ed\u300d\u4e0e\u300c\u5f53\u524d\u4f1a\u8bdd\u5173\u95ed\u300d\u4e24\u79cd\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5168\u5c40\u5173\u95ed\uff08\u6c38\u4e45\u751f\u6548\uff09<\/strong>\uff1a<\/li>\n<\/ul>\n\n\n\n<pre id=\"XcahH\" class=\"wp-block-code\"><code># 1. \u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\nvim \/data\/mysql\/conf\/my.cnf\n\n# 2. \u6ce8\u91ca\u539f log-bin \u914d\u7f6e\n# log-bin = \/data\/mysql\/binlog\/mysql-bin\n\n# 3. \u6dfb\u52a0\u5173\u95ed\u53c2\u6570\uff08\u4e8c\u9009\u4e00\u5373\u53ef\uff09\nskip_log_bin\n# \u6216\ndisable_log_bin\n\n# 4. \u91cd\u542f MySQL \u670d\u52a1\n\/etc\/init.d\/mysql.server restart\n\n# 5. \u9a8c\u8bc1\u5173\u95ed\u7ed3\u679c\nshow variables like '%log_bin%';<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5f53\u524d\u4f1a\u8bdd\u5173\u95ed\uff08\u4e34\u65f6\u751f\u6548\uff0c\u91cd\u542f\u540e\u5931\u6548\uff09<\/strong>\uff1a<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u9002\u7528\u4e8e\u4e34\u65f6\u65e0\u9700\u8bb0\u5f55\u65e5\u5fd7\u7684\u573a\u666f\uff0c\u6267\u884c SQL \u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre id=\"HUknm\" class=\"wp-block-code\"><code>set sql_log_bin = 0;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"qwjh2\">4. \u914d\u7f6e Binlog \u5927\u5c0f\u9650\u5236<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"ua5630081\">\u9ed8\u8ba4\u5355\u4e2a Binlog \u6587\u4ef6\u6700\u5927\u4e3a 1G\uff0c\u53ef\u901a\u8fc7\u914d\u7f6e\u8c03\u6574\uff0c\u907f\u514d\u6587\u4ef6\u8fc7\u5927\u5f71\u54cd\u7ba1\u7406\uff1a<\/p>\n\n\n\n<pre id=\"QH1PU\" class=\"wp-block-code\"><code># 1. \u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\nvim \/data\/mysql\/conf\/my.cnf\n\n# 2. \u6dfb\u52a0\u5927\u5c0f\u9650\u5236\uff08\u793a\u4f8b\uff1a\u8bbe\u7f6e\u4e3a 512M\uff09\nmax-binlog-size = 512M\n\n# 3. \u91cd\u542f MySQL \u670d\u52a1\n\/etc\/init.d\/mysql.server restart\n\n# 4. \u9a8c\u8bc1\u914d\u7f6e\nshow variables like 'max_binlog_size';\n\n# 5. \uff08\u53ef\u9009\uff09\u5355\u4f4d\u6362\u7b97\uff1a\u5c06\u5b57\u8282\u6570\u8f6c\u4e3a GB\uff08\u793a\u4f8b\uff09\nselect @@max_binlog_size \/ 1024 \/ 1024 \/ 1024 as max_binlog_size_gb;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"VqaeE\">\u4e8c\u3001Binlog \u4e09\u5927\u6838\u5fc3\u4f5c\u7528<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u4e3b\u4ece\u590d\u5236\u57fa\u77f3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3b\u4ece\u590d\u5236\u7684\u6838\u5fc3\u6d41\u7a0b\u4f9d\u8d56 Binlog \u5b9e\u73b0\uff1a\u200b<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e3b\u5e93\uff1a\u5c06\u6240\u6709\u6570\u636e\u53d8\u66f4\u64cd\u4f5c\u8bb0\u5f55\u5230 Binlog \u65e5\u5fd7\u200b<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4ece\u5e93\uff1a\u901a\u8fc7 IO \u7ebf\u7a0b\u8bfb\u53d6\u4e3b\u5e93\u7684 Binlog\uff0c\u5199\u5165\u672c\u5730\u4e2d\u7ee7\u65e5\u5fd7\u200b<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4ece\u5e93\uff1a\u901a\u8fc7 SQL \u7ebf\u7a0b\u56de\u653e\u4e2d\u7ee7\u65e5\u5fd7\uff0c\u5b9e\u73b0\u4e0e\u4e3b\u5e93\u7684\u6570\u636e\u540c\u6b65\u200b<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u673a\u5236\u53ef\u5206\u62c5\u4e3b\u5e93\u8bfb\u5199\u538b\u529b\uff0c\u63d0\u5347\u7cfb\u7edf\u53ef\u7528\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u6570\u636e\u5907\u4efd\u4e0e\u6062\u590d<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u53d1\u751f\u8bef\u64cd\u4f5c\uff08\u5982\u8bef\u5220\u8868\u3001\u8bef\u66f4\u65b0\uff09\u65f6\uff0cBinlog \u53ef\u914d\u5408\u5168\u91cf\u5907\u4efd\u5b9e\u73b0\u6570\u636e\u6062\u590d\uff1a\u200b<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u5148\u6062\u590d\u6700\u8fd1\u7684\u5168\u91cf\u5907\u4efd\uff0c\u5c06\u6570\u636e\u5e93\u8fd8\u539f\u81f3\u5907\u4efd\u65f6\u95f4\u70b9\u200b<\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u63d0\u53d6\u5168\u91cf\u5907\u4efd\u540e\u81f3\u8bef\u64cd\u4f5c\u524d\u7684 Binlog \u65e5\u5fd7\u200b<\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u6267\u884c Binlog \u65e5\u5fd7\u4e2d\u7684\u5408\u6cd5\u64cd\u4f5c\uff08\u6392\u9664\u8bef\u64cd\u4f5c\uff09\uff0c\u5373\u53ef\u8fd8\u539f\u6570\u636e<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u8de8\u5e93\u8fc1\u79fb\u652f\u6491<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 MySQL \u5411 TiDB\u3001ClickHouse \u7b49\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u65f6\uff0cBinlog \u53d1\u6325\u5173\u952e\u4f5c\u7528\uff1a\u200b<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u901a\u8fc7 Canal\u3001Otter \u7b49\u5de5\u5177\u76d1\u542c Binlog \u65e5\u5fd7\u200b<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b9e\u65f6\u6355\u6349\u589e\u91cf\u6570\u636e\u53d8\u66f4\u200b<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06\u53d8\u66f4\u540c\u6b65\u81f3\u76ee\u6807\u6570\u636e\u5e93\uff0c\u5b9e\u73b0\u65e0\u611f\u77e5\u8fc1\u79fb\uff0c\u4fdd\u969c\u4e1a\u52a1\u8fde\u7eed\u6027<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Binlog \u4f5c\u4e3a MySQL \u7684\u6838\u5fc3\u65e5\u5fd7\u7ec4\u4ef6\uff0c\u5176\u914d\u7f6e\u5408\u7406\u6027\u76f4\u63a5\u5f71\u54cd\u6570\u636e\u53ef\u9760\u6027\u4e0e\u7cfb\u7edf\u6269\u5c55\u6027\u3002\u5efa\u8bae\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u5408\u7406\u8bbe\u7f6e\u65e5\u5fd7\u5927\u5c0f\u3001\u4fdd\u7559\u7b56\u7565\uff0c\u540c\u65f6\u7ed3\u5408\u5168\u91cf\u5907\u4efd\u5b9a\u671f\u9a8c\u8bc1 Binlog \u53ef\u7528\u6027\u3002\u65e0\u8bba\u662f\u4e3b\u4ece\u67b6\u6784\u642d\u5efa\u3001\u6570\u636e\u5b89\u5168\u4fdd\u969c\u8fd8\u662f\u8de8\u5e93\u8fc1\u79fb\uff0cBinlog \u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u6280\u672f\u652f\u6491\uff0c\u638c\u63e1\u5176\u914d\u7f6e\u4e0e\u5e94\u7528\u573a\u666f\u80fd\u6709\u6548\u63d0\u5347\u6570\u636e\u5e93\u8fd0\u7ef4\u6548\u7387\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a MySQL \u8de8\u5b58\u50a8\u5f15\u64ce\u7684\u6838\u5fc3\u65e5\u5fd7\u7ec4\u4ef6\uff0cBinlog\uff08\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff09\u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u4e2d\u6240\u6709\u6570\u636e\u4fee\u6539\u64cd\u4f5c\uff0c\u662f\u4e3b\u4ece\u590d<\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"https:\/\/yunyanglib.cn\/?p=278\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[16],"class_list":["post-278","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/posts\/278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=278"}],"version-history":[{"count":4,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions\/898"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=\/wp\/v2\/media\/282"}],"wp:attachment":[{"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yunyanglib.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}