{"id":100868,"date":"2026-09-05T14:17:09","date_gmt":"2026-09-05T06:17:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/100868.html"},"modified":"2026-09-05T14:17:09","modified_gmt":"2026-09-05T06:17:09","slug":"%e3%80%90mysql%e3%80%91binlog%e8%a7%a3%e6%9e%90%e5%85%a8%e6%94%bb%e7%95%a5%ef%bc%9a5%e7%a7%8d%e5%9c%ba%e6%99%af%e5%ae%9e%e6%93%8d%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/100868.html","title":{"rendered":"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4"},"content":{"rendered":"<h3>\u4e00\u3001Binlog \u662f\u4ec0\u4e48&#xff1f;\u4e3a\u4ec0\u4e48\u9700\u8981\u89e3\u6790\u5b83&#xff1f;<\/h3>\n<p>Binlog&#xff0c;\u5168\u79f0 Binary Log&#xff08;\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff09;&#xff0c;\u662f MySQL Server \u5c42\u4ea7\u751f\u7684\u4e00\u79cd\u903b\u8f91\u65e5\u5fd7&#xff0c;\u7528\u4e8e\u8bb0\u5f55\u6240\u6709\u53ef\u80fd\u5f15\u8d77\u6570\u636e\u53d8\u66f4\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u5b83\u4e0e InnoDB \u7684 redo log\u3001undo log \u4e0d\u540c&#xff1a;redo log \u548c undo log \u662f\u5b58\u50a8\u5f15\u64ce\u5c42\u7684\u7269\u7406\/\u903b\u8f91\u65e5\u5fd7&#xff0c;\u800c Binlog \u662f\u4e0a\u5c42 MySQL Server \u8bb0\u5f55\u7684\u3001\u53ef\u4ee5\u88ab\u5916\u90e8\u7a0b\u5e8f\u8bfb\u61c2\u7684\u201c\u6570\u636e\u53d8\u66f4\u6d41\u6c34\u8d26\u201d\u3002<\/p>\n<p>\u901a\u4fd7\u5730\u8bf4&#xff0c;Binlog \u5c31\u50cf\u662f\u6570\u636e\u5e93\u7684\u201c\u884c\u8f66\u8bb0\u5f55\u4eea\u201d\u3002\u6bcf\u4e00\u6b21\u63d2\u5165\u3001\u66f4\u65b0\u3001\u5220\u9664&#xff0c;\u751a\u81f3 DDL&#xff08;\u5efa\u8868\u3001\u6539\u8868&#xff09;\u64cd\u4f5c&#xff0c;\u90fd\u4f1a\u88ab\u6309\u7167\u63d0\u4ea4\u987a\u5e8f\u8bb0\u5f55\u5176\u4e2d\u3002\u53ea\u8981 Binlog \u8fd8\u4fdd\u5b58\u7740&#xff0c;\u7406\u8bba\u4e0a\u4f60\u5c31\u53ef\u4ee5\u201c\u56de\u653e\u201d\u8fd9\u4e9b\u64cd\u4f5c&#xff0c;\u628a\u6570\u636e\u6062\u590d\u5230\u67d0\u4e2a\u5386\u53f2\u65f6\u523b\u3002<\/p>\n<p>\u89e3\u6790 Binlog&#xff0c;\u6307\u7684\u662f\u4f7f\u7528\u5de5\u5177\u6216\u7f16\u5199\u7a0b\u5e8f&#xff0c;\u628a Binlog \u6587\u4ef6\u4e2d\u4e8c\u8fdb\u5236\u683c\u5f0f\u7684\u4e8b\u4ef6\u7ffb\u8bd1\u6210\u4eba\u7c7b\u53ef\u8bfb\u7684 SQL \u6216\u7ed3\u6784\u5316\u6570\u636e&#xff0c;\u8fdb\u800c\u670d\u52a1\u4e8e\u5404\u79cd\u4e1a\u52a1\u76ee\u6807\u3002\u4e3a\u4ec0\u4e48\u8981\u89e3\u6790 Binlog&#xff1f;\u56e0\u4e3a\u5b83\u627f\u62c5\u7740\u4ee5\u4e0b\u51e0\u9879\u5173\u952e\u804c\u8d23&#xff1a;<\/p>\n<ul>\n<li>\u4e3b\u4ece\u590d\u5236&#xff1a;MySQL \u4e3b\u4ece\u590d\u5236\u6b63\u662f\u901a\u8fc7\u628a\u4e3b\u5e93\u7684 Binlog \u4f20\u9012\u7ed9\u4ece\u5e93&#xff0c;\u7531\u4ece\u5e93\u7684 I\/O \u7ebf\u7a0b\u5199\u5165 relay log&#xff0c;\u518d\u7531 SQL \u7ebf\u7a0b\u91cd\u653e&#xff0c;\u4ece\u800c\u5b9e\u73b0\u6570\u636e\u540c\u6b65\u3002\u7406\u89e3 Binlog \u662f\u6392\u67e5\u590d\u5236\u95ee\u9898\u7684\u524d\u63d0\u3002<\/li>\n<li>\u6570\u636e\u6062\u590d&#xff1a;\u5f53\u53d1\u751f\u8bef\u5220\u9664\u3001\u8bef\u66f4\u65b0\u65f6&#xff0c;\u5982\u679c\u5f00\u542f\u4e86 Binlog&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u89e3\u6790\u5e76\u56de\u653e\u6307\u5b9a\u65f6\u95f4\u6bb5\u7684\u4e8b\u4ef6&#xff0c;\u6216\u8005\u901a\u8fc7\u201c\u9006\u64cd\u4f5c\u201d\u5b9e\u73b0\u7cbe\u786e\u6062\u590d&#xff0c;\u6700\u5927\u9650\u5ea6\u51cf\u5c11\u635f\u5931\u3002<\/li>\n<li>\u5ba1\u8ba1\u4e0e\u5408\u89c4&#xff1a;\u5bf9\u4e8e\u91d1\u878d\u3001\u533b\u7597\u7b49\u5f3a\u76d1\u7ba1\u884c\u4e1a&#xff0c;\u9700\u8981\u8bb0\u5f55\u201c\u8c01\u5728\u4ec0\u4e48\u65f6\u95f4\u6539\u4e86\u4ec0\u4e48\u6570\u636e\u201d\u3002\u89e3\u6790 Binlog \u53ef\u4ee5\u8fd8\u539f\u5b8c\u6574\u7684\u53d8\u66f4\u94fe\u8def\u3002<\/li>\n<li>\u589e\u91cf\u540c\u6b65\u4e0e\u6570\u636e\u7ba1\u9053&#xff1a;\u628a MySQL \u7684\u589e\u91cf\u53d8\u66f4\u5b9e\u65f6\u540c\u6b65\u5230 Elasticsearch\u3001Kafka\u3001Redis\u3001\u6570\u636e\u4ed3\u5e93\u6216\u7f13\u5b58\u7cfb\u7edf&#xff0c;\u662f\u5f88\u591a\u6570\u636e\u4e2d\u53f0\u7684\u6838\u5fc3\u80fd\u529b&#xff0c;\u5e95\u5c42\u90fd\u4f9d\u8d56 Binlog \u89e3\u6790\u3002<\/li>\n<li>\u7f13\u5b58\u4e00\u81f4\u6027&#xff1a;\u901a\u8fc7\u76d1\u542c Binlog \u53d8\u66f4&#xff0c;\u53ef\u4ee5\u5b9e\u73b0\u7f13\u5b58\u7684\u5f02\u6b65\u5931\u6548\u6216\u66f4\u65b0&#xff0c;\u907f\u514d\u53cc\u5199\u4e0d\u4e00\u81f4\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u7531\u6b64\u53ef\u89c1&#xff0c;\u638c\u63e1 Binlog \u89e3\u6790\u4e0d\u4ec5\u662f DBA \u7684\u5fc5\u4fee\u8bfe&#xff0c;\u4e5f\u662f\u540e\u7aef\u5de5\u7a0b\u5e08\u3001\u5927\u6570\u636e\u5de5\u7a0b\u5e08\u6784\u5efa\u6570\u636e\u57fa\u7840\u8bbe\u65bd\u65f6\u7684\u91cd\u8981\u6280\u80fd\u3002\u672c\u6587\u5c06\u4ece\u57fa\u7840\u6982\u5ff5\u3001\u683c\u5f0f\u539f\u7406\u3001\u5de5\u5177\u4f7f\u7528\u5230 5 \u79cd\u5178\u578b\u573a\u666f\u7684\u5b8c\u6574\u5b9e\u64cd&#xff0c;\u5e26\u4f60\u7cfb\u7edf\u638c\u63e1 Binlog \u89e3\u6790\u7684\u65b9\u6cd5\u8bba\u3002<\/p>\n<h3>\u4e8c\u3001Binlog \u7684\u4e09\u79cd\u683c\u5f0f\u4e0e\u5bf9\u6bd4<\/h3>\n<p>\u5728\u6df1\u5165\u89e3\u6790\u4e4b\u524d&#xff0c;\u5fc5\u987b\u5148\u641e\u6e05\u695a Binlog \u7684\u4e8b\u4ef6\u683c\u5f0f\u3002MySQL \u63d0\u4f9b\u4e86\u4e09\u79cd Binlog \u683c\u5f0f&#xff0c;\u7406\u89e3\u5b83\u4eec\u7684\u5dee\u5f02\u662f\u6b63\u786e\u89e3\u6790\u7684\u524d\u63d0\u3002<\/p>\n<h4>2.1 STATEMENT \u683c\u5f0f<\/h4>\n<p>STATEMENT \u683c\u5f0f\u4e0b&#xff0c;Binlog \u8bb0\u5f55\u7684\u662f\u903b\u8f91 SQL \u8bed\u53e5\u672c\u8eab&#xff0c;\u4f8b\u5982\u4e00\u6761 UPDATE users SET age &#061; age &#043; 1 WHERE id &#061; 100 \u4f1a\u88ab\u539f\u6837\u8bb0\u5f55\u3002\u5b83\u7684\u4f18\u70b9\u662f\u65e5\u5fd7\u91cf\u5c0f\u3001\u53ef\u8bfb\u6027\u5f3a&#xff0c;\u4f46\u95ee\u9898\u5728\u4e8e\u5f88\u591a\u8bed\u53e5\u5728\u4e3b\u4ece\u5e93\u4e4b\u95f4\u91cd\u653e\u65f6\u53ef\u80fd\u4ea7\u751f\u4e0d\u540c\u7ed3\u679c&#xff0c;\u5c24\u5176\u662f\u5305\u542b NOW()\u3001UUID()\u3001RAND() \u7b49\u975e\u786e\u5b9a\u6027\u51fd\u6570&#xff0c;\u6216\u8005\u4f7f\u7528 LIMIT \u4e14\u6ca1\u6709\u6392\u5e8f\u6761\u4ef6\u7684\u8bed\u53e5&#xff0c;\u5bb9\u6613\u5bfc\u81f4\u4e3b\u4ece\u6570\u636e\u4e0d\u4e00\u81f4\u3002<\/p>\n<h4>2.2 ROW \u683c\u5f0f<\/h4>\n<p>ROW \u683c\u5f0f\u4e0d\u8bb0\u5f55 SQL \u8bed\u53e5\u672c\u8eab&#xff0c;\u800c\u662f\u8bb0\u5f55\u6bcf\u4e00\u884c\u6570\u636e\u53d8\u66f4\u524d\u540e\u7684\u5b8c\u6574\u5feb\u7167\u3002\u5bf9\u4e8e UPDATE&#xff0c;\u5b83\u8bb0\u5f55\u4fee\u6539\u524d\u7684\u65e7\u503c\u548c\u4fee\u6539\u540e\u7684\u65b0\u503c&#xff1b;\u5bf9\u4e8e DELETE&#xff0c;\u8bb0\u5f55\u88ab\u5220\u9664\u884c\u7684\u65e7\u503c&#xff1b;\u5bf9\u4e8e INSERT&#xff0c;\u8bb0\u5f55\u63d2\u5165\u884c\u7684\u65b0\u503c\u3002ROW \u683c\u5f0f\u7684\u4f18\u70b9\u662f\u5b89\u5168\u3001\u7cbe\u786e&#xff0c;\u80fd\u591f\u4fdd\u8bc1\u4e3b\u4ece\u4e00\u81f4\u6027&#xff0c;\u5c24\u5176\u9002\u5408\u8bef\u5220\u6062\u590d\u3001\u7cbe\u786e\u5ba1\u8ba1\u7b49\u573a\u666f\u3002\u7f3a\u70b9\u662f\u65e5\u5fd7\u4f53\u79ef\u66f4\u5927&#xff0c;\u5c24\u5176\u5f53\u4e00\u6761 SQL \u5f71\u54cd\u5927\u91cf\u884c\u65f6&#xff0c;\u6bcf\u4e00\u884c\u90fd\u4f1a\u751f\u6210\u4e00\u6761\u4e8b\u4ef6\u3002<\/p>\n<h4>2.3 MIXED \u683c\u5f0f<\/h4>\n<p>MIXED \u683c\u5f0f\u662f STATEMENT \u548c ROW \u7684\u6298\u4e2d\u65b9\u6848&#xff0c;\u9ed8\u8ba4\u4ee5 STATEMENT \u683c\u5f0f\u8bb0\u5f55&#xff0c;MySQL \u4f1a\u6839\u636e\u8bed\u53e5\u7684\u5177\u4f53\u60c5\u51b5\u81ea\u52a8\u5224\u65ad&#xff1a;\u5982\u679c\u8bed\u53e5\u5b58\u5728\u4e0d\u786e\u5b9a\u6027\u6216\u7279\u6b8a\u884c\u4e3a&#xff0c;\u5c31\u5207\u6362\u4e3a ROW \u683c\u5f0f\u8bb0\u5f55\u3002\u5b83\u8bd5\u56fe\u5728\u65e5\u5fd7\u4f53\u79ef\u4e0e\u4e00\u81f4\u6027\u4e4b\u95f4\u53d6\u5f97\u5e73\u8861&#xff0c;\u4f46\u5728\u5b9e\u9645\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u4e3a\u4e86\u53ef\u9760\u6027\u548c\u53ef\u89e3\u6790\u6027&#xff0c;\u5f3a\u70c8\u63a8\u8350\u4f7f\u7528 ROW \u683c\u5f0f\u3002<\/p>\n<h4>2.4 \u4e09\u79cd\u683c\u5f0f\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6STATEMENTROWMIXED<\/tr>\n<tbody>\n<tr>\n<td>\u8bb0\u5f55\u5185\u5bb9<\/td>\n<td>SQL \u8bed\u53e5<\/td>\n<td>\u884c\u7ea7\u6570\u636e\u53d8\u66f4<\/td>\n<td>\u4e24\u8005\u6df7\u5408<\/td>\n<\/tr>\n<tr>\n<td>\u65e5\u5fd7\u4f53\u79ef<\/td>\n<td>\u5c0f<\/td>\n<td>\u5927<\/td>\n<td>\u4e2d\u7b49<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u8bfb\u6027<\/td>\n<td>\u9ad8<\/td>\n<td>\u8f83\u4f4e&#xff0c;\u9700\u501f\u52a9\u5de5\u5177<\/td>\n<td>\u4e2d\u7b49<\/td>\n<\/tr>\n<tr>\n<td>\u4e3b\u4ece\u4e00\u81f4\u6027<\/td>\n<td>\u53ef\u80fd\u4e0d\u4e00\u81f4<\/td>\n<td>\u5f3a\u4e00\u81f4<\/td>\n<td>\u8f83\u597d<\/td>\n<\/tr>\n<tr>\n<td>\u6062\u590d\u7cbe\u5ea6<\/td>\n<td>\u4f9d\u8d56\u8bed\u53e5\u91cd\u653e<\/td>\n<td>\u53ef\u8fd8\u539f\u6bcf\u4e00\u884c<\/td>\n<td>\u4f9d\u8d56\u5b9e\u9645\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>\u5ba1\u8ba1\u80fd\u529b<\/td>\n<td>\u53ea\u80fd\u770b\u5230\u8bed\u53e5<\/td>\n<td>\u53ef\u770b\u5230\u5177\u4f53\u884c\u53d8\u66f4<\/td>\n<td>\u90e8\u5206\u53ef\u5ba1\u8ba1<\/td>\n<\/tr>\n<tr>\n<td>\u63a8\u8350\u7a0b\u5ea6<\/td>\n<td>\u4e0d\u63a8\u8350\u751f\u4ea7\u4f7f\u7528<\/td>\n<td>\u5f3a\u70c8\u63a8\u8350<\/td>\n<td>\u4e00\u822c\u4e0d\u63a8\u8350<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7ed3\u8bba\u5f88\u660e\u786e&#xff1a;\u9664\u975e\u6709\u7279\u6b8a\u5386\u53f2\u517c\u5bb9\u539f\u56e0&#xff0c;\u5426\u5219\u751f\u4ea7\u73af\u5883\u8bf7\u9009\u62e9 ROW \u683c\u5f0f\u3002\u672c\u6587\u540e\u7eed\u7684\u89e3\u6790\u4e0e\u5b9e\u64cd\u5747\u4ee5 ROW \u683c\u5f0f\u4e3a\u57fa\u51c6\u3002<\/p>\n<h3>\u4e09\u3001Binlog \u89e3\u6790\u524d\u7684\u51c6\u5907\u5de5\u4f5c<\/h3>\n<p>\u89e3\u6790 Binlog \u4e4b\u524d&#xff0c;\u9700\u8981\u5148\u786e\u8ba4\u6570\u636e\u5e93\u662f\u5426\u5df2\u7ecf\u6b63\u786e\u5f00\u542f Binlog&#xff0c;\u5e76\u4e86\u89e3\u76f8\u5173\u914d\u7f6e\u3002\u5f88\u591a\u521d\u7ea7\u95ee\u9898\u90fd\u6e90\u4e8e Binlog \u6ca1\u6709\u5f00\u542f\u6216\u683c\u5f0f\u4e0d\u5bf9\u3002<\/p>\n<h4>3.1 \u67e5\u770b Binlog \u662f\u5426\u5f00\u542f<\/h4>\n<p>SHOW VARIABLES LIKE &#039;log_bin&#039;;<\/p>\n<p>\u5982\u679c\u8fd4\u56de Value &#061; ON&#xff0c;\u8bf4\u660e\u5df2\u7ecf\u5f00\u542f&#xff1b;\u5982\u679c\u4e3a OFF&#xff0c;\u9700\u8981\u4fee\u6539\u914d\u7f6e\u5e76\u91cd\u542f MySQL\u3002<\/p>\n<h4>3.2 \u6838\u5fc3\u914d\u7f6e\u53c2\u6570<\/h4>\n<p>[mysqld]<br \/>\nserver-id &#061; 1<br \/>\nlog_bin &#061; \/var\/lib\/mysql\/mysql-bin<br \/>\nbinlog_format &#061; ROW<br \/>\nbinlog_row_image &#061; FULL<br \/>\nexpire_logs_days &#061; 7<br \/>\nmax_binlog_size &#061; 512M<br \/>\nsync_binlog &#061; 1<\/p>\n<p>\u5404\u53c2\u6570\u542b\u4e49\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>server-id&#xff1a;\u670d\u52a1\u5668\u552f\u4e00\u6807\u8bc6&#xff0c;\u4e3b\u4ece\u590d\u5236\u65f6\u6bcf\u53f0\u673a\u5668\u5fc5\u987b\u4e0d\u540c&#xff0c;\u7f3a\u5c11\u6b64\u53c2\u6570 Binlog \u4e0d\u4f1a\u88ab\u8bb0\u5f55\u3002<\/li>\n<li>log_bin&#xff1a;\u6307\u5b9a Binlog \u6587\u4ef6\u8def\u5f84\u524d\u7f00&#xff0c;\u5f00\u542f\u540e\u4f1a\u751f\u6210\u5f62\u5982 mysql-bin.000001 \u7684\u6587\u4ef6\u3002<\/li>\n<li>binlog_format&#xff1a;\u63a8\u8350\u8bbe\u7f6e\u4e3a ROW\u3002<\/li>\n<li>binlog_row_image&#xff1a;FULL \u8bb0\u5f55\u5b8c\u6574\u7684\u524d\u540e\u955c\u50cf&#xff0c;\u9002\u5408\u505a\u7cbe\u786e\u6062\u590d\u548c\u5ba1\u8ba1&#xff1b;MINIMAL \u53ea\u8bb0\u5f55\u53d8\u66f4\u5217&#xff0c;\u53ef\u7701\u7a7a\u95f4\u4f46\u4f1a\u4e22\u5931\u90e8\u5206\u5ba1\u8ba1\u4fe1\u606f\u3002<\/li>\n<li>expire_logs_days&#xff1a;Binlog \u81ea\u52a8\u6e05\u7406\u5929\u6570&#xff0c;\u751f\u4ea7\u73af\u5883\u5efa\u8bae 7&#xff5e;14 \u5929&#xff0c;\u914d\u5408\u5907\u4efd\u7b56\u7565\u4f7f\u7528\u3002<\/li>\n<li>max_binlog_size&#xff1a;\u5355\u4e2a Binlog \u6587\u4ef6\u5927\u5c0f\u4e0a\u9650&#xff0c;\u8d85\u8fc7\u540e\u81ea\u52a8\u6eda\u52a8\u751f\u6210\u65b0\u6587\u4ef6\u3002<\/li>\n<li>sync_binlog&#xff1a;\u63a7\u5236 Binlog \u843d\u76d8\u9891\u7387&#xff0c;1 \u8868\u793a\u6bcf\u6b21\u63d0\u4ea4\u90fd\u540c\u6b65\u843d\u76d8&#xff0c;\u6700\u5b89\u5168\u4f46\u6027\u80fd\u7565\u4f4e&#xff0c;\u8d44\u91d1\u4ea4\u6613\u7b49\u6838\u5fc3\u7cfb\u7edf\u5efa\u8bae\u8bbe\u7f6e\u4e3a 1\u3002<\/li>\n<\/ul>\n<h4>3.3 \u67e5\u770b\u5df2\u5b58\u5728\u7684 Binlog \u6587\u4ef6<\/h4>\n<p>SHOW BINARY LOGS;<\/p>\n<p>\u8fd4\u56de\u7ed3\u679c\u4f1a\u5217\u51fa\u6240\u6709 Binlog \u6587\u4ef6\u540d\u53ca\u5927\u5c0f\u3002\u6b64\u5916&#xff0c;SHOW MASTER STATUS \u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6b63\u5728\u5199\u5165\u7684 Binlog \u6587\u4ef6\u53ca\u504f\u79fb\u4f4d\u7f6e\u3002<\/p>\n<p>SHOW MASTER STATUS;<\/p>\n<p>\u8fd9\u4e09\u6761\u547d\u4ee4\u662f\u65e5\u5e38\u6392\u67e5\u65f6\u4f7f\u7528\u9891\u7387\u6700\u9ad8\u7684\u201c\u4e09\u677f\u65a7\u201d&#xff0c;\u5efa\u8bae\u719f\u7ec3\u638c\u63e1\u3002<\/p>\n<h3>\u56db\u3001\u6838\u5fc3\u5de5\u5177 mysqlbinlog \u5b8c\u5168\u6307\u5357<\/h3>\n<p>mysqlbinlog \u662f MySQL \u5b98\u65b9\u63d0\u4f9b\u7684 Binlog \u89e3\u6790\u5de5\u5177&#xff0c;\u901a\u5e38\u968f MySQL \u5ba2\u6237\u7aef\u4e00\u8d77\u53d1\u5e03\u3002\u5b83\u662f\u547d\u4ee4\u884c\u573a\u666f\u4e0b\u6700\u76f4\u63a5\u3001\u6700\u53ef\u9760\u7684\u89e3\u6790\u624b\u6bb5\u3002<\/p>\n<h4>4.1 \u6700\u57fa\u672c\u7684\u89e3\u6790\u65b9\u5f0f<\/h4>\n<p>mysqlbinlog \/var\/lib\/mysql\/mysql-bin.000001<\/p>\n<p>\u8fd9\u6761\u547d\u4ee4\u4f1a\u4ee5\u4f2a SQL \u7684\u5f62\u5f0f\u6253\u5370 Binlog \u5185\u5bb9\u3002\u5bf9\u4e8e STATEMENT \u683c\u5f0f&#xff0c;\u4f60\u80fd\u76f4\u63a5\u770b\u5230\u539f\u59cb\u7684 SQL \u8bed\u53e5&#xff1b;\u4f46\u5bf9\u4e8e ROW \u683c\u5f0f&#xff0c;\u9ed8\u8ba4\u8f93\u51fa\u4e2d\u884c\u4e8b\u4ef6\u53ea\u662f\u4e00\u4e32 base64 \u7f16\u7801\u7684\u4e8c\u8fdb\u5236\u5185\u5bb9&#xff0c;\u51e0\u4e4e\u65e0\u6cd5\u76f4\u63a5\u9605\u8bfb&#xff0c;\u5fc5\u987b\u52a0\u4e0a\u89e3\u7801\u53c2\u6570\u3002<\/p>\n<h4>4.2 \u89e3\u6790 ROW \u683c\u5f0f\u4e8b\u4ef6<\/h4>\n<p>mysqlbinlog &#8211;base64-output&#061;DECODE-ROWS -v \/var\/lib\/mysql\/mysql-bin.000001<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>&#8211;base64-output&#061;DECODE-ROWS&#xff1a;\u628a ROW \u4e8b\u4ef6\u7684 base64 \u5185\u5bb9\u89e3\u7801\u663e\u793a\u3002<\/li>\n<li>-v&#xff08;verbose&#xff09;&#xff1a;\u8f93\u51fa\u884c\u6570\u636e\u65f6\u6a21\u62df SQL \u8bed\u53e5&#xff0c;\u4ee5\u6ce8\u91ca\u5f62\u5f0f\u5c55\u793a\u53d8\u66f4\u7684\u524d\u540e\u503c&#xff0c;\u4fbf\u4e8e\u9605\u8bfb\u3002<\/li>\n<li>-vv&#xff1a;\u66f4\u8be6\u7ec6\u5730\u663e\u793a\u5217\u540d\u3001\u7c7b\u578b\u4ee5\u53ca\u65e7\u503c\/\u65b0\u503c\u7684\u5bf9\u7167\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982&#xff0c;\u4e00\u6761 UPDATE \u5728 -vv \u6a21\u5f0f\u4e0b\u4f1a\u663e\u793a\u7c7b\u4f3c\u5982\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p>### UPDATE &#096;test&#096;.&#096;users&#096;<br \/>\n### WHERE<br \/>\n###   &#064;1&#061;100<br \/>\n###   &#064;2&#061;&#039;tom&#039;<br \/>\n###   &#064;3&#061;25<br \/>\n### SET<br \/>\n###   &#064;1&#061;100<br \/>\n###   &#064;2&#061;&#039;tom&#039;<br \/>\n###   &#064;3&#061;26<\/p>\n<p>\u8fd9\u91cc &#064;N \u8868\u793a\u8be5\u8868\u7684\u7b2c N \u5217&#xff0c;WHERE \u90e8\u5206\u4e3a\u65e7\u503c&#xff0c;SET \u90e8\u5206\u4e3a\u65b0\u503c\u3002\u8fd9\u79cd\u8f93\u51fa\u5bf9\u4e8e\u6570\u636e\u5ba1\u8ba1\u548c\u6062\u590d\u975e\u5e38\u76f4\u89c2\u3002<\/p>\n<h4>4.3 \u6309\u65f6\u95f4\u8303\u56f4\u8fc7\u6ee4<\/h4>\n<p>\u5904\u7406\u8bef\u5220\u6062\u590d\u65f6&#xff0c;\u901a\u5e38\u53ea\u9700\u8981\u89e3\u6790\u67d0\u4e2a\u65f6\u95f4\u6bb5\u7684\u4e8b\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528\u8d77\u59cb\u65f6\u95f4\u548c\u7ed3\u675f\u65f6\u95f4\u8fc7\u6ee4&#xff1a;<\/p>\n<p>mysqlbinlog &#8211;start-datetime&#061;&#034;2026-08-30 10:00:00&#034; \\\\<br \/>\n            &#8211;stop-datetime&#061;&#034;2026-08-30 11:00:00&#034; \\\\<br \/>\n            &#8211;base64-output&#061;DECODE-ROWS -v \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000001<\/p>\n<h4>4.4 \u6309\u4f4d\u7f6e\u8fc7\u6ee4<\/h4>\n<p>\u5982\u679c\u5df2\u7ecf\u901a\u8fc7 SHOW MASTER STATUS \u6216\u4e8b\u4ef6\u5217\u8868\u786e\u5b9a\u4e86\u8d77\u6b62\u504f\u79fb\u91cf&#xff0c;\u53ef\u4ee5\u7528 &#8211;start-position \u548c &#8211;stop-position \u7cbe\u786e\u5b9a\u4f4d&#xff1a;<\/p>\n<p>mysqlbinlog &#8211;start-position&#061;1234 &#8211;stop-position&#061;5678 \\\\<br \/>\n            &#8211;base64-output&#061;DECODE-ROWS -v \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000001<\/p>\n<h4>4.5 \u6309\u6570\u636e\u5e93\u548c\u8868\u8fc7\u6ee4<\/h4>\n<p>mysqlbinlog &#8211;database&#061;test \\\\<br \/>\n            &#8211;tables&#061;users,orders \\\\<br \/>\n            &#8211;base64-output&#061;DECODE-ROWS -v \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000001<\/p>\n<p>\u6ce8\u610f&#xff1a;&#8211;database \u53ea\u80fd\u6839\u636e\u9ed8\u8ba4\u5e93\u8fc7\u6ee4&#xff0c;\u5bf9\u4e8e\u8de8\u5e93\u64cd\u4f5c\u7528\u9014\u6709\u9650&#xff1b;&#8211;tables \u5728\u8f83\u65b0\u7248\u672c\u4e2d\u652f\u6301\u6307\u5b9a\u8868\u540d&#xff0c;\u80fd\u8fdb\u4e00\u6b65\u7f29\u5c0f\u8303\u56f4\u3002<\/p>\n<h4>4.6 \u8fdc\u7a0b\u89e3\u6790<\/h4>\n<p>mysqlbinlog \u4e5f\u652f\u6301\u8fde\u63a5\u8fdc\u7a0b MySQL \u5b9e\u4f8b\u76f4\u63a5\u8bfb\u53d6&#xff1a;<\/p>\n<p>mysqlbinlog &#8211;read-from-remote-server \\\\<br \/>\n            &#8211;host&#061;192.168.1.100 &#8211;port&#061;3306 \\\\<br \/>\n            &#8211;user&#061;root &#8211;password &#8211;raw \\\\<br \/>\n            mysql-bin.000001<\/p>\n<p>\u914d\u5408 &#8211;raw \u53c2\u6570\u53ef\u4ee5\u76f4\u63a5\u628a\u8fdc\u7a0b Binlog \u62c9\u53d6\u4e3a\u672c\u5730\u6587\u4ef6&#xff0c;\u4fbf\u4e8e\u79bb\u7ebf\u5206\u6790\u3002\u4e0d\u8fc7\u751f\u4ea7\u73af\u5883\u901a\u5e38\u4e0d\u5efa\u8bae\u76f4\u8fde\u751f\u4ea7\u5e93\u8bfb\u53d6 Binlog&#xff0c;\u5efa\u8bae\u5148\u628a\u6587\u4ef6\u62f7\u8d1d\u5230\u5206\u6790\u673a\u518d\u89e3\u6790\u3002<\/p>\n<h4>4.7 \u5c06\u89e3\u6790\u7ed3\u679c\u5e94\u7528\u5230\u6570\u636e\u5e93<\/h4>\n<p>\u89e3\u6790\u540e\u5982\u679c\u5e0c\u671b\u628a\u4e8b\u4ef6\u91cd\u653e\u5230\u76ee\u6807\u5e93&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u7ba1\u9053\u7ed9 mysql \u5ba2\u6237\u7aef&#xff1a;<\/p>\n<p>mysqlbinlog &#8211;base64-output&#061;DECODE-ROWS -v \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000001 | \\\\<br \/>\n            mysql -h \u76ee\u6807\u4e3b\u673a -u \u7528\u6237\u540d -p \u76ee\u6807\u5e93<\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u5e38\u7528\u4e8e\u6570\u636e\u6062\u590d\u4e2d\u7684\u201c\u6b63\u5411\u91cd\u653e\u201d\u573a\u666f\u3002\u4f46\u9700\u8981\u6ce8\u610f\u8fc7\u6ee4\u6389\u8bef\u64cd\u4f5c\u672c\u8eab\u7684\u4e8b\u4ef6&#xff0c;\u5426\u5219\u4f1a\u628a\u9519\u8bef\u64cd\u4f5c\u91cd\u65b0\u6267\u884c\u4e00\u904d\u3002<\/p>\n<h3>\u4e94\u30015 \u79cd\u5178\u578b\u4e1a\u52a1\u573a\u666f\u4e0e\u5b9e\u64cd\u6b65\u9aa4<\/h3>\n<p>\u672c\u7ae0\u662f\u5168\u6587\u7684\u6838\u5fc3&#xff0c;\u9010\u4e00\u62c6\u89e3 5 \u79cd\u6700\u5e38\u89c1\u7684 Binlog \u89e3\u6790\u5e94\u7528\u573a\u666f&#xff0c;\u5e76\u7ed9\u51fa\u53ef\u843d\u5730\u7684\u5b9e\u64cd\u6b65\u9aa4\u3002\u6240\u6709\u64cd\u4f5c\u5747\u4ee5\u542f\u7528 ROW \u683c\u5f0f\u7684 MySQL 8.0 \u4e3a\u6f14\u793a\u73af\u5883\u3002<\/p>\n<h4>\u573a\u666f\u4e00&#xff1a;\u8bef\u5220\u9664\u6570\u636e\u540e\u7684\u7cbe\u786e\u6062\u590d<\/h4>\n<p>\u8fd9\u662f DBA \u548c\u5f00\u53d1\u6700\u5e38\u9047\u5230\u7684\u7d27\u6025\u4e8b\u6545\u3002\u5047\u8bbe\u67d0\u4f4d\u540c\u4e8b\u5728 10:30 \u5de6\u53f3\u8bef\u6267\u884c\u4e86 DELETE FROM orders WHERE status &#061; &#039;draft&#039;&#xff0c;\u5220\u9664\u4e86\u5927\u91cf\u4e0d\u5e94\u8be5\u5220\u9664\u7684\u8349\u7a3f\u8ba2\u5355&#xff0c;\u9700\u8981\u5c3d\u5feb\u6062\u590d\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u786e\u8ba4\u8bef\u64cd\u4f5c\u65f6\u95f4\u70b9\u4e0e Binlog \u8303\u56f4\u3002\u5148\u67e5\u770b\u5f53\u524d\u6b63\u5728\u5199\u5165\u7684 Binlog \u6587\u4ef6&#xff1a;<\/p>\n<p>SHOW MASTER STATUS;<\/p>\n<p>\u5047\u8bbe\u7ed3\u679c\u4e3a mysql-bin.000008\u3002\u5982\u679c\u8bef\u64cd\u4f5c\u53d1\u751f\u5728\u66f4\u65e9\u7684\u6587\u4ef6&#xff0c;\u9700\u8981\u901a\u8fc7 SHOW BINARY LOGS \u627e\u5230\u8986\u76d6\u8be5\u65f6\u95f4\u6bb5\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u89e3\u6790\u8be5\u65f6\u95f4\u6bb5\u7684 ROW \u4e8b\u4ef6\u3002<\/p>\n<p>mysqlbinlog &#8211;start-datetime&#061;&#034;2026-08-30 10:25:00&#034; \\\\<br \/>\n            &#8211;stop-datetime&#061;&#034;2026-08-30 10:35:00&#034; \\\\<br \/>\n            &#8211;database&#061;shop &#8211;tables&#061;orders \\\\<br \/>\n            &#8211;base64-output&#061;DECODE-ROWS -vv \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000008 &gt; delete_events.sql<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u4ece\u8f93\u51fa\u4e2d\u63d0\u53d6\u88ab\u5220\u9664\u884c\u7684\u65e7\u503c\u3002ROW \u683c\u5f0f\u4e0b&#xff0c;DELETE \u4e8b\u4ef6\u4f1a\u4ee5 ### DELETE FROM \u548c ### WHERE \u7684\u5f62\u5f0f\u5c55\u793a\u88ab\u5220\u9664\u884c\u7684\u5b8c\u6574\u5b57\u6bb5\u503c\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p>### DELETE FROM &#096;shop&#096;.&#096;orders&#096;<br \/>\n### WHERE<br \/>\n###   &#064;1&#061;20260830001<br \/>\n###   &#064;2&#061;&#039;draft&#039;<br \/>\n###   &#064;3&#061;88.50<br \/>\n###   &#064;4&#061;&#039;2026-08-29 18:20:00&#039;<\/p>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u5c06\u65e7\u503c\u8f6c\u6362\u4e3a INSERT \u8bed\u53e5\u3002\u53ef\u4ee5\u624b\u5de5\u6574\u7406&#xff0c;\u4e5f\u53ef\u4ee5\u7528\u811a\u672c\u81ea\u52a8\u751f\u6210\u3002\u5bf9\u4e8e\u6279\u91cf\u573a\u666f&#xff0c;\u63a8\u8350\u7528 awk \u6216 python \u811a\u672c\u89e3\u6790\u6ce8\u91ca\u884c\u5e76\u62fc\u88c5 INSERT&#xff0c;\u6700\u540e\u5bfc\u5165\u6570\u636e\u5e93&#xff1a;<\/p>\n<p>mysql -h \u6062\u590d\u76ee\u6807\u5e93 -u root -p shop &lt; restore_insert.sql<\/p>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u6062\u590d\u524d\u5148\u786e\u8ba4\u76ee\u6807\u5e93\u6570\u636e\u72b6\u6001&#xff0c;\u907f\u514d\u91cd\u590d\u63d2\u5165\u5bfc\u81f4\u4e3b\u952e\u51b2\u7a81&#xff0c;\u5fc5\u8981\u65f6\u4f7f\u7528 INSERT IGNORE \u6216\u5148\u5907\u4efd\u5f53\u524d\u6570\u636e\u3002<\/li>\n<li>\u5982\u679c ROW \u4e8b\u4ef6\u65f6\u95f4\u8de8\u5ea6\u8f83\u957f&#xff0c;\u5efa\u8bae\u6309\u4f4d\u7f6e&#xff08;position&#xff09;\u800c\u4e0d\u662f\u65f6\u95f4\u8fc7\u6ee4&#xff0c;\u56e0\u4e3a\u65f6\u95f4\u7cbe\u5ea6\u4e3a\u79d2&#xff0c;\u53ef\u80fd\u9057\u6f0f\u540c\u4e00\u79d2\u5185\u7684\u5176\u4ed6\u4e8b\u4ef6\u3002<\/li>\n<li>\u751f\u4ea7\u73af\u5883\u5e94\u4f18\u5148\u57fa\u4e8e\u5168\u91cf\u5907\u4efd &#043; Binlog \u589e\u91cf\u505a Point-in-Time Recovery&#xff08;PITR&#xff09;&#xff0c;\u800c\u4e0d\u662f\u5355\u9760\u624b\u5de5\u62fc SQL\u3002<\/li>\n<\/ul>\n<h4>\u573a\u666f\u4e8c&#xff1a;\u4e3b\u4ece\u590d\u5236\u5ef6\u8fdf\u4e0e\u9519\u8bef\u6392\u67e5<\/h4>\n<p>\u4e3b\u4ece\u590d\u5236\u51fa\u73b0\u5ef6\u8fdf\u6216\u4e2d\u65ad\u65f6&#xff0c;\u901a\u8fc7\u89e3\u6790 Binlog \u53ef\u4ee5\u5feb\u901f\u5b9a\u4f4d\u201c\u5361\u4f4f\u7684\u4e8b\u4ef6\u201d\u4ee5\u53ca\u5bfc\u81f4\u95ee\u9898\u7684 SQL\u3002\u5178\u578b\u75c7\u72b6\u662f\u4ece\u5e93\u7684 Seconds_Behind_Master \u6301\u7eed\u589e\u5927&#xff0c;\u6216\u8005 SQL \u7ebf\u7a0b\u62a5\u9519\u505c\u6b62\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u67e5\u770b\u4ece\u5e93\u590d\u5236\u72b6\u6001\u3002<\/p>\n<p>SHOW SLAVE STATUS\\\\G<\/p>\n<p>\u91cd\u70b9\u5173\u6ce8 Slave_IO_Running\u3001Slave_SQL_Running\u3001Last_Errno\u3001Last_Error&#xff0c;\u4ee5\u53ca Relay_Master_Log_File \u548c Exec_Master_Log_Pos\u3002\u5982\u679c SQL \u7ebf\u7a0b\u62a5\u9519&#xff0c;\u9519\u8bef\u4fe1\u606f\u901a\u5e38\u4f1a\u6307\u51fa\u5177\u4f53\u539f\u56e0&#xff0c;\u4f8b\u5982\u4e3b\u952e\u51b2\u7a81\u3001\u5b57\u6bb5\u4e0d\u5b58\u5728\u7b49\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u6839\u636e\u9519\u8bef\u4fe1\u606f\u5b9a\u4f4d\u4e3b\u5e93\u5bf9\u5e94\u7684 Binlog \u4f4d\u7f6e\u3002\u590d\u5236\u51fa\u9519\u65f6&#xff0c;\u4e3b\u5e93\u5bf9\u5e94\u7684\u4e8b\u4ef6\u5c31\u4f4d\u4e8e Relay_Master_Log_File \u6307\u5b9a\u7684\u6587\u4ef6\u4e2d&#xff0c;\u7ed3\u5408 Exec_Master_Log_Pos \u5373\u53ef\u5b9a\u4f4d\u3002\u5047\u8bbe\u9519\u8bef\u65e5\u5fd7\u663e\u793a\u4e3b\u952e\u51b2\u7a81\u53d1\u751f\u5728 mysql-bin.000010 \u7684 position 54321 \u9644\u8fd1&#xff1a;<\/p>\n<p>mysqlbinlog &#8211;start-position&#061;54200 &#8211;stop-position&#061;54500 \\\\<br \/>\n            &#8211;base64-output&#061;DECODE-ROWS -vv \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000010<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u5206\u6790\u76ee\u6807\u4e8b\u4ef6\u3002\u5982\u679c\u53d1\u73b0\u662f\u4e00\u6761 INSERT \u5728\u4ece\u5e93\u6267\u884c\u65f6\u4e3b\u952e\u51b2\u7a81&#xff0c;\u8bf4\u660e\u4ece\u5e93\u5df2\u7ecf\u5b58\u5728\u8be5\u4e3b\u952e\u6570\u636e&#xff0c;\u5f88\u53ef\u80fd\u662f\u4ece\u5e93\u88ab\u4eba\u5de5\u4fee\u6539\u8fc7&#xff0c;\u6216\u4e4b\u524d\u672a\u5f00\u542f read_only \u5bfc\u81f4\u8bef\u5199\u5165\u3002<\/p>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u9009\u62e9\u5904\u7406\u7b56\u7565\u3002\u5e38\u89c1\u505a\u6cd5\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\u5982\u679c\u4e3b\u5e93\u6570\u636e\u6b63\u786e\u4e14\u4ece\u5e93\u591a\u51fa\u7684\u6570\u636e\u662f\u810f\u6570\u636e&#xff0c;\u53ef\u5728\u4ece\u5e93\u5220\u9664\u51b2\u7a81\u884c\u540e&#xff0c;\u8ba9\u5b83\u7ee7\u7eed\u6267\u884c\u51fa\u9519\u7684\u4e8b\u4ef6\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u8df3\u8fc7\u9519\u8bef&#xff0c;\u53ef\u4ee5\u4f7f\u7528 SET GLOBAL sql_slave_skip_counter &#061; 1; \u8df3\u8fc7\u5f53\u524d\u4e8b\u52a1&#xff0c;\u4f46\u8df3\u8fc7\u540e\u53ef\u80fd\u9020\u6210\u6570\u636e\u4e0d\u4e00\u81f4&#xff0c;\u5fc5\u987b\u8c28\u614e\u8bc4\u4f30\u3002<\/li>\n<li>\u66f4\u7a33\u59a5\u7684\u65b9\u6cd5\u662f\u505c\u6b62\u590d\u5236&#xff0c;\u628a\u4ece\u5e93\u6062\u590d\u5230\u4e3b\u5e93\u7684\u4e00\u81f4\u5feb\u7167&#xff0c;\u91cd\u65b0\u5f00\u542f\u590d\u5236\u3002<\/li>\n<\/ul>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;\u6392\u67e5\u590d\u5236\u5ef6\u8fdf\u65f6&#xff0c;\u9664\u4e86\u770b Binlog \u5185\u5bb9&#xff0c;\u8fd8\u8981\u5173\u6ce8\u4e3b\u5e93\u5199\u5165\u538b\u529b\u3001\u4ece\u5e93\u786c\u4ef6\u6027\u80fd\u3001\u7f51\u7edc\u5e26\u5bbd\u4ee5\u53ca\u5927\u4e8b\u52a1\u7684\u5f71\u54cd\u3002\u4e00\u4e2a\u957f\u65f6\u95f4\u672a\u63d0\u4ea4\u7684\u5927\u4e8b\u52a1\u5373\u4f7f\u53ea\u5305\u542b\u4e00\u6761 SQL&#xff0c;\u4e5f\u4f1a\u5728\u63d0\u4ea4\u65f6\u628a\u5927\u91cf ROW \u4e8b\u4ef6\u5199\u5165 Binlog&#xff0c;\u5bfc\u81f4\u4ece\u5e93\u91cd\u653e\u65f6\u95f4\u53d8\u957f\u3002<\/p>\n<h4>\u573a\u666f\u4e09&#xff1a;\u6570\u636e\u53d8\u66f4\u5ba1\u8ba1\u4e0e\u5408\u89c4\u8ffd\u8e2a<\/h4>\n<p>\u5728\u91d1\u878d\u3001\u652f\u4ed8\u7b49\u5f3a\u76d1\u7ba1\u7cfb\u7edf\u4e2d&#xff0c;\u9700\u8981\u56de\u7b54\u201c\u67d0\u6761\u8bb0\u5f55\u5728\u4ec0\u4e48\u65f6\u95f4\u88ab\u8c01\u6539\u6210\u4e86\u4ec0\u4e48\u503c\u201d\u3002ROW \u683c\u5f0f\u7684 Binlog \u53ef\u4ee5\u5929\u7136\u652f\u6301\u8fd9\u79cd\u5ba1\u8ba1\u9700\u6c42&#xff0c;\u56e0\u4e3a\u5b83\u8bb0\u5f55\u4e86\u6bcf\u884c\u6570\u636e\u53d8\u66f4\u7684\u524d\u540e\u955c\u50cf\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u786e\u5b9a\u8981\u5ba1\u8ba1\u7684\u8868\u548c\u65f6\u95f4\u8303\u56f4\u3002\u4f8b\u5982\u8981\u5ba1\u8ba1 account.balance \u8868\u5728 8 \u6708 30 \u65e5\u5168\u5929\u7684\u6240\u6709\u53d8\u66f4\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u89e3\u6790\u5e76\u8f93\u51fa\u4e3a\u7ed3\u6784\u5316\u6570\u636e\u3002\u867d\u7136 mysqlbinlog \u7684 verbose \u8f93\u51fa\u53ef\u8bfb&#xff0c;\u4f46\u5e76\u4e0d\u9002\u5408\u81ea\u52a8\u5ba1\u8ba1\u3002\u63a8\u8350\u4f7f\u7528\u652f\u6301\u7ed3\u6784\u5316\u7684\u89e3\u6790\u5e93\u6216\u4e2d\u95f4\u4ef6&#xff0c;\u6bd4\u5982 Canal\u3001Maxwell\u3001Debezium&#xff0c;\u6216\u8005 Java \u7684 mysql-binlog-connector-java \u5e93\u3002\u4e0b\u9762\u662f\u4f7f\u7528 mysqlbinlog \u5feb\u901f\u5bfc\u51fa\u4ee5\u4f9b\u811a\u672c\u5206\u6790\u7684\u547d\u4ee4&#xff1a;<\/p>\n<p>mysqlbinlog &#8211;start-datetime&#061;&#034;2026-08-30 00:00:00&#034; \\\\<br \/>\n            &#8211;stop-datetime&#061;&#034;2026-08-30 23:59:59&#034; \\\\<br \/>\n            &#8211;database&#061;account &#8211;tables&#061;balance \\\\<br \/>\n            &#8211;base64-output&#061;DECODE-ROWS -vv \\\\<br \/>\n            \/var\/lib\/mysql\/mysql-bin.000011 &gt; audit_balance.log<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u7f16\u5199\u89e3\u6790\u811a\u672c\u63d0\u53d6\u5b57\u6bb5\u3002\u4ee5 Python \u4e3a\u4f8b&#xff0c;\u53ef\u4ee5\u9010\u884c\u626b\u63cf ### &#064;N&#061;\u503c \u8fd9\u6837\u7684\u6ce8\u91ca\u884c&#xff0c;\u7ed3\u5408\u8868\u7ed3\u6784\u5143\u6570\u636e\u8fd8\u539f\u5b57\u6bb5\u540d&#xff1a;<\/p>\n<p>import re<br \/>\ndef parse_events(log_file):<br \/>\nevent &#061; None<br \/>\nwith open(log_file, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\nfor line in f:<br \/>\nif line.startswith(&#034;### UPDATE&#034;) or line.startswith(&#034;### DELETE&#034;) or line.startswith(&#034;### INSERT&#034;):<br \/>\nevent &#061; {&#034;type&#034;: line.split()[1], &#034;rows&#034;: []}<br \/>\nelif line.startswith(&#034;###&#034;) and &#034;&#064;&#034; in line and event:<br \/>\nm &#061; re.findall(r&#034;&#064;(\\\\d&#043;)&#061;(.&#043;)&#034;, line)<br \/>\nif m:<br \/>\nevent[&#034;rows&#034;].append({int(idx): val for idx, val in m})<br \/>\nreturn event<br \/>\nevents &#061; parse_events(&#034;audit_balance.log&#034;)<br \/>\nprint(events)<\/p>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u5173\u8054\u64cd\u4f5c\u8005\u4fe1\u606f\u3002Binlog \u672c\u8eab\u4e0d\u8bb0\u5f55\u201c\u54ea\u4e2a\u7528\u6237\u6267\u884c\u4e86\u64cd\u4f5c\u201d&#xff0c;\u53ea\u8bb0\u5f55\u4f1a\u8bdd\u7684 thread_id\u3002\u8981\u5b8c\u6574\u5ba1\u8ba1&#xff0c;\u9700\u8981\u540c\u65f6\u5f00\u542f\u5ba1\u8ba1\u63d2\u4ef6&#xff08;\u5982 Percona Audit Plugin \u6216 MySQL Enterprise Audit&#xff09;&#xff0c;\u6216\u8005\u4ece\u5e94\u7528\u5c42\u65e5\u5fd7\u4e0e\u4f1a\u8bdd\u4fe1\u606f\u4e2d\u5173\u8054 thread_id \u4e0e\u7528\u6237\u8eab\u4efd\u3002\u751f\u4ea7\u73af\u5883\u7684\u5408\u89c4\u5ba1\u8ba1\u901a\u5e38\u662f\u201cBinlog \u53d8\u66f4\u8f68\u8ff9 &#043; \u5ba1\u8ba1\u63d2\u4ef6\u8eab\u4efd\u4fe1\u606f\u201d\u7684\u7ec4\u5408\u65b9\u6848\u3002<\/p>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;\u5ba1\u8ba1\u9700\u6c42\u5bf9 binlog_row_image&#061;FULL \u662f\u521a\u9700&#xff0c;\u5982\u679c\u4e4b\u524d\u914d\u7f6e\u6210 MINIMAL&#xff0c;\u5c06\u65e0\u6cd5\u8fd8\u539f\u672a\u53d8\u66f4\u5b57\u6bb5\u7684\u5b8c\u6574\u503c&#xff0c;\u5ba1\u8ba1\u4ef7\u503c\u5927\u6253\u6298\u6263\u3002<\/p>\n<h4>\u573a\u666f\u56db&#xff1a;\u5c06 MySQL \u589e\u91cf\u540c\u6b65\u5230 Kafka \/ Elasticsearch<\/h4>\n<p>\u6570\u636e\u4e2d\u53f0\u7ecf\u5e38\u9700\u8981\u628a MySQL \u7684\u5728\u7ebf\u53d8\u66f4\u5b9e\u65f6\u540c\u6b65\u5230 Kafka\u3001Elasticsearch\u3001\u6570\u4ed3\u6216\u7f13\u5b58\u7cfb\u7edf\u3002\u81ea\u7814\u4e00\u4e2a\u7a33\u5b9a\u3001\u4f4e\u5ef6\u8fdf\u7684\u540c\u6b65\u7ba1\u9053\u6210\u672c\u5f88\u9ad8&#xff0c;\u56e0\u6b64\u4e1a\u754c\u666e\u904d\u91c7\u7528\u57fa\u4e8e Binlog \u89e3\u6790\u7684\u4e2d\u95f4\u4ef6\u3002\u4e0b\u9762\u662f\u4e09\u79cd\u4e3b\u6d41\u65b9\u6848\u53ca\u5176\u5b9e\u64cd\u8981\u70b9\u3002<\/p>\n<p>\u65b9\u6848 A&#xff1a;Canal\u3002\u963f\u91cc\u5f00\u6e90\u7684 MySQL Binlog \u589e\u91cf\u8ba2\u9605\u4e0e\u6d88\u8d39\u7ec4\u4ef6&#xff0c;\u6a21\u62df MySQL Slave \u7684\u4ea4\u4e92\u534f\u8bae&#xff0c;\u5411\u4e3b\u5e93\u8bf7\u6c42 Binlog \u5e76\u89e3\u6790&#xff0c;\u5c06\u53d8\u66f4\u63a8\u5230\u4e0b\u6e38\u3002Canal \u90e8\u7f72\u65f6\u9700\u8981\u5728 MySQL \u4e0a\u5f00\u542f Binlog \u5e76\u6388\u6743\u4e00\u4e2a\u590d\u5236\u8d26\u53f7&#xff1a;<\/p>\n<p>CREATE USER &#039;canal&#039;&#064;&#039;%&#039; IDENTIFIED BY &#039;canal&#039;;<br \/>\nGRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO &#039;canal&#039;&#064;&#039;%&#039;;<br \/>\nFLUSH PRIVILEGES;<\/p>\n<p>\u968f\u540e\u5728 Canal \u7684 instance.properties \u4e2d\u914d\u7f6e\u6e90\u5e93\u5730\u5740\u3001\u8d26\u53f7\u4ee5\u53ca\u8981\u76d1\u542c\u7684\u5e93\u8868&#xff0c;\u542f\u52a8\u540e\u53d8\u66f4\u4e8b\u4ef6\u4f1a\u4ee5 Canal \u534f\u8bae\u8f93\u51fa&#xff0c;\u5b98\u65b9\u63d0\u4f9b\u4e86 Java \u5ba2\u6237\u7aef\u793a\u4f8b&#xff0c;\u53ef\u4ee5\u65b9\u4fbf\u5730\u6d88\u8d39\u5e76\u5199\u5165 Kafka\u3002<\/p>\n<p>\u65b9\u6848 B&#xff1a;Maxwell\u3002\u57fa\u4e8e Zendesk \u5f00\u6e90\u7684\u8f7b\u91cf\u7ea7 Binlog \u89e3\u6790\u5668&#xff0c;\u7279\u70b9\u662f\u8f93\u51fa JSON \u683c\u5f0f&#xff0c;\u5929\u7136\u9002\u914d Kafka\u3002\u5b83\u4ee5 row \u4e3a\u5355\u4f4d\u8f93\u51fa&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;database&#034;: &#034;shop&#034;,<br \/>\n  &#034;table&#034;: &#034;orders&#034;,<br \/>\n  &#034;type&#034;: &#034;insert&#034;,<br \/>\n  &#034;ts&#034;: 1785456000,<br \/>\n  &#034;data&#034;: {&#034;id&#034;: &#034;20260830001&#034;, &#034;status&#034;: &#034;draft&#034;, &#034;amount&#034;: 88.5}<br \/>\n}<\/p>\n<p>Maxwell \u652f\u6301\u914d\u7f6e Kafka \u7684 bootstrap servers \u548c topic&#xff0c;\u5c06\u4e0d\u540c\u5e93\u8868\u7684\u53d8\u66f4\u8def\u7531\u5230\u4e0d\u540c topic&#xff0c;\u975e\u5e38\u9002\u5408\u4e8b\u4ef6\u9a71\u52a8\u67b6\u6784\u3002<\/p>\n<p>\u65b9\u6848 C&#xff1a;Debezium\u3002\u57fa\u4e8e Kafka Connect \u7684 CDC&#xff08;Change Data Capture&#xff09;\u67b6\u6784&#xff0c;\u751f\u6001\u4e0e Kafka \u7ed3\u5408\u6700\u6df1\u3002\u5b83\u901a\u8fc7 Kafka Connect \u63d2\u4ef6\u6355\u83b7 MySQL Binlog&#xff0c;\u5c06\u6bcf\u6b21\u53d8\u66f4\u8f93\u51fa\u4e3a\u5305\u542b before \u548c after \u7ed3\u6784\u7684\u6d88\u606f&#xff0c;\u5e76\u7ef4\u62a4 offset \u4ee5\u786e\u4fdd\u6545\u969c\u6062\u590d\u540e\u4e0d\u4e22\u4e0d\u91cd\u3002<\/p>\n<p>\u5b9e\u64cd\u6b65\u9aa4\u6458\u8981&#xff1a;<\/p>\n<li>\u786e\u8ba4 MySQL \u5f00\u542f Binlog&#xff08;ROW \u683c\u5f0f&#xff09;&#xff0c;\u5e76\u521b\u5efa\u5177\u5907\u590d\u5236\u6743\u9650\u7684\u8d26\u53f7\u3002<\/li>\n<li>\u90e8\u7f72\u5e76\u914d\u7f6e\u9009\u5b9a\u7684\u540c\u6b65\u7ec4\u4ef6&#xff0c;\u6307\u5b9a\u6e90\u5e93\u3001\u76d1\u542c\u8868\u3001\u8f93\u51fa\u76ee\u6807&#xff08;Kafka\u3001ES \u7b49&#xff09;\u3002<\/li>\n<li>\u5148\u505a\u4e00\u6b21\u5168\u91cf\u5feb\u7167\u540c\u6b65&#xff0c;\u518d\u542f\u52a8\u589e\u91cf\u6d88\u8d39&#xff0c;\u4e8c\u8005\u8854\u63a5\u540e\u5b8c\u6210\u521d\u59cb\u4e00\u81f4\u6027\u3002<\/li>\n<li>\u9a8c\u8bc1\u6d88\u606f\u7684 before\/after \u5b57\u6bb5\u4e0e\u4e1a\u52a1\u8868\u7ed3\u6784\u4e00\u81f4&#xff0c;\u5e76\u5904\u7406\u5b57\u6bb5\u7c7b\u578b\u6620\u5c04&#xff08;\u5982 DECIMAL\u3001DATETIME\u3001TINYINT(1) \u7684 Java \u7c7b\u578b\u8f6c\u6362&#xff09;\u3002<\/li>\n<li>\u76d1\u63a7\u6d88\u8d39\u5ef6\u8fdf\u3001offset \u63d0\u4ea4\u548c\u5f02\u5e38\u91cd\u8bd5&#xff0c;\u4fdd\u8bc1\u6700\u7ec8\u4e00\u81f4\u6027\u3002<\/li>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;\u8fd9\u7c7b\u540c\u6b65\u7ba1\u9053\u7684\u6838\u5fc3\u6311\u6218\u4e0d\u5728\u89e3\u6790\u672c\u8eab&#xff0c;\u800c\u5728\u5168\u91cf\/\u589e\u91cf\u8854\u63a5\u3001\u5927\u4e8b\u52a1\u62c6\u5206\u3001\u4e0b\u6e38\u5e42\u7b49\u5199\u5165\u548c\u6545\u969c\u6062\u590d\u3002\u8bbe\u8ba1\u65f6\u5fc5\u987b\u660e\u786e\u81f3\u5c11\u4e00\u6b21\u6295\u9012\u8bed\u4e49&#xff0c;\u5e76\u5728\u4e0b\u6e38\u505a\u597d\u5e42\u7b49\u53bb\u91cd\u3002<\/p>\n<h4>\u573a\u666f\u4e94&#xff1a;\u4f7f\u7528\u95ea\u56de\u5de5\u5177\u56de\u6eda\u8bef\u64cd\u4f5c\u7684 UPDATE \/ DELETE<\/h4>\n<p>\u573a\u666f\u4e00\u4ecb\u7ecd\u7684\u662f\u201c\u6b63\u5411\u6062\u590d\u201d&#xff0c;\u5373\u6839\u636e DELETE \u4e8b\u4ef6\u7684\u65e7\u503c\u91cd\u65b0 INSERT \u56de\u6765\u3002\u95ea\u56de&#xff08;Flashback&#xff09;\u5219\u662f\u201c\u9006\u5411\u751f\u6210\u201d&#xff0c;\u5373\u6839\u636e UPDATE\/DELETE \u4e8b\u4ef6\u81ea\u52a8\u751f\u6210\u76f8\u53cd\u7684 SQL \u6765\u64a4\u9500\u64cd\u4f5c&#xff0c;\u6bd4\u5982\u5c06 UPDATE \u7684\u65b0\u503c\u6362\u56de\u65e7\u503c&#xff0c;\u5c06 DELETE \u53d8\u6210 INSERT\u3002\u8fd9\u79cd\u65b9\u6cd5\u7279\u522b\u9002\u5408 UPDATE \u8bef\u64cd\u4f5c&#xff0c;\u56e0\u4e3a\u6b63\u5411\u6062\u590d\u5f88\u96be\u62fc\u51fa\u5b8c\u6574 UPDATE \u6d88\u9664\u5f71\u54cd\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u786e\u8ba4\u8bef\u64cd\u4f5c\u4e8b\u4ef6\u7684\u8303\u56f4\u3002\u4e0e\u573a\u666f\u4e00\u76f8\u540c&#xff0c;\u5148\u786e\u5b9a\u8bef\u64cd\u4f5c\u53d1\u751f\u7684\u65f6\u95f4\u70b9\u4e0e\u5bf9\u5e94\u7684 Binlog \u6587\u4ef6\u53ca position\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u4f7f\u7528\u95ea\u56de\u5de5\u5177\u751f\u6210\u56de\u6eda SQL\u3002MySQL \u5b98\u65b9\u5e76\u672a\u5185\u7f6e\u95ea\u56de\u5de5\u5177&#xff0c;\u4f46\u53ef\u4ee5\u4f7f\u7528\u793e\u533a\u65b9\u6848\u3002\u4f8b\u5982\u7f8e\u56e2\u5f00\u6e90\u7684 MyFlash&#xff0c;\u4ee5\u53ca\u57fa\u4e8e mysqlbinlog \u7684 binlog2sql&#xff08;\u4e00\u4e2a\u6d41\u884c\u7684 Python \u5de5\u5177&#xff09;\u3002\u4ee5 binlog2sql \u4e3a\u4f8b&#xff1a;<\/p>\n<p># \u6b63\u5411\u89e3\u6790&#xff1a;\u67e5\u770b\u8bef\u64cd\u4f5c\u5f71\u54cd\u7684\u884c<br \/>\npython binlog2sql.py -h127.0.0.1 -P3306 -uroot -p&#039;\u5bc6\u7801&#039; \\\\<br \/>\n  &#8211;start-file&#061;&#039;mysql-bin.000012&#039; &#8211;start-datetime&#061;&#039;2026-08-30 11:00:00&#039; \\\\<br \/>\n  &#8211;stop-datetime&#061;&#039;2026-08-30 11:05:00&#039; -d shop -t orders<br \/>\n\u751f\u6210\u95ea\u56de SQL&#xff1a;\u52a0 -B \u53c2\u6570\u53cd\u89e3\u51fa\u56de\u6eda\u8bed\u53e5<br \/>\npython binlog2sql.py -B -h127.0.0.1 -P3306 -uroot -p&#039;\u5bc6\u7801&#039;<br \/>\n&#8211;start-file&#061;&#039;mysql-bin.000012&#039; &#8211;start-datetime&#061;&#039;2026-08-30 11:00:00&#039;<br \/>\n&#8211;stop-datetime&#061;&#039;2026-08-30 11:05:00&#039; -d shop -t orders &gt; rollback.sql<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u5ba1\u6838\u56de\u6eda SQL \u540e\u6267\u884c\u3002\u751f\u6210\u7684 rollback.sql \u4f1a\u5305\u542b\u4e0e\u8bef\u64cd\u4f5c\u76f8\u53cd\u7684\u8bed\u53e5\u3002\u4f8b\u5982\u539f\u64cd\u4f5c\u662f UPDATE orders SET amount &#061; 100 WHERE id &#061; 1&#xff0c;\u95ea\u56de\u5de5\u5177\u4f1a\u6839\u636e ROW \u4e8b\u4ef6\u7684\u65e7\u503c\u751f\u6210 UPDATE orders SET amount &#061; 88.5 WHERE id &#061; 1\u3002\u6267\u884c\u524d\u52a1\u5fc5\u4eba\u5de5\u5ba1\u6838&#xff1a;<\/p>\n<p>mysql -h \u6062\u590d\u76ee\u6807\u5e93 -u root -p shop &lt; rollback.sql<\/p>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u6821\u9a8c\u6062\u590d\u7ed3\u679c\u3002\u5bf9\u6bd4\u8bef\u64cd\u4f5c\u524d\u540e\u6570\u636e&#xff0c;\u786e\u8ba4\u5173\u952e\u884c\u5df2\u6062\u590d\u5230\u8bef\u64cd\u4f5c\u524d\u7684\u503c\u3002\u6ce8\u610f\u95ea\u56de\u53ea\u5bf9\u5df2\u8bb0\u5f55\u5728 Binlog \u4e2d\u7684\u53d8\u66f4\u6709\u6548&#xff0c;\u5982\u679c\u76ee\u6807\u884c\u5728\u8bef\u64cd\u4f5c\u4e4b\u540e\u53c8\u88ab\u5176\u4ed6\u4e8b\u52a1\u4fee\u6539\u8fc7&#xff0c;\u56de\u6eda\u53ef\u80fd\u8986\u76d6\u6b63\u5e38\u53d8\u66f4&#xff0c;\u6240\u4ee5\u5fc5\u987b\u5c3d\u5feb\u6267\u884c\u3001\u63a7\u5236\u7ade\u4e89\u3002<\/p>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;\u95ea\u56de\u662f\u5e94\u6025\u624b\u6bb5\u800c\u975e\u4e07\u80fd\u836f&#xff0c;\u5b83\u4f9d\u8d56 ROW \u683c\u5f0f\u548c binlog_row_image&#061;FULL&#xff0c;\u5e76\u4e14\u8981\u6c42\u8bef\u64cd\u4f5c\u540e\u6ca1\u6709\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u4fee\u6539\u540c\u4e00\u6279\u884c\u3002\u5bf9\u4e8e\u6570\u636e\u91cf\u5de8\u5927\u7684\u8bef\u64cd\u4f5c&#xff0c;\u95ea\u56de SQL \u53ef\u80fd\u975e\u5e38\u5e9e\u5927&#xff0c;\u6267\u884c\u524d\u8981\u8bc4\u4f30\u5bf9\u6027\u80fd\u7684\u5f71\u54cd&#xff0c;\u5efa\u8bae\u5206\u6279\u63d0\u4ea4\u3002<\/p>\n<h3>\u516d\u3001\u7f16\u7a0b\u65b9\u5f0f\u89e3\u6790 Binlog<\/h3>\n<p>\u547d\u4ee4\u884c\u5de5\u5177\u9002\u5408\u6392\u67e5\u548c\u4e00\u6b21\u6027\u7684\u6062\u590d\u4efb\u52a1&#xff0c;\u4f46\u5728\u5b9e\u65f6\u8ba1\u7b97\u3001\u6570\u636e\u7ba1\u9053\u7b49\u573a\u666f\u4e2d&#xff0c;\u9700\u8981\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u6301\u7eed\u8ba2\u9605\u5e76\u89e3\u6790 Binlog\u3002Java \u751f\u6001\u4e2d&#xff0c;mysql-binlog-connector-java \u662f\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u8f7b\u91cf\u7ea7\u5e93\u4e4b\u4e00&#xff0c;\u5b83\u5b9e\u73b0\u4e86 MySQL \u590d\u5236\u534f\u8bae&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u50cf Slave \u4e00\u6837\u62c9\u53d6 Binlog \u6d41\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u5f15\u5165\u4f9d\u8d56\u3002<\/p>\n<p>&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;com.github.shyiko&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;mysql-binlog-connector-java&lt;\/artifactId&gt;<br \/>\n    &lt;version&gt;0.29.2&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt;<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u6838\u5fc3\u8ba2\u9605\u4ee3\u7801\u3002<\/p>\n<p>import com.github.shyiko.mysql.binlog.BinaryLogClient;<br \/>\nimport com.github.shyiko.mysql.binlog.event.*;<br \/>\nimport com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer;<br \/>\npublic class BinlogParserDemo {<br \/>\npublic static void main(String[] args) throws Exception {<br \/>\n    BinaryLogClient client &#061; new BinaryLogClient(&#034;192.168.1.100&#034;, 3306, &#034;canal&#034;, &#034;canal&#034;);<br \/>\nEventDeserializer deserializer &#061; new EventDeserializer();<br \/>\ndeserializer.setCompatibilityMode(<br \/>\n    EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG,<br \/>\n    EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY<br \/>\n);<br \/>\nclient.setEventDeserializer(deserializer);<br \/>\nclient.registerEventListener(event -&amp;amp;gt; {<br \/>\nEventData data &#061; event.getData();<br \/>\nif (data instanceof WriteRowsEventData) {<br \/>\nWriteRowsEventData writeData &#061; (WriteRowsEventData) data;<br \/>\nSystem.out.println(&#034;INSERT into &#034; &#043; writeData.getTableId());<br \/>\nfor (Object[] row : writeData.getRows()) {<br \/>\nfor (Object column : row) {<br \/>\nSystem.out.print(column &#043; &#034;\\\\t&#034;);<br \/>\n}<br \/>\nSystem.out.println();<br \/>\n}<br \/>\n} else if (data instanceof UpdateRowsEventData) {<br \/>\nUpdateRowsEventData updateData &#061; (UpdateRowsEventData) data;<br \/>\nSystem.out.println(&#034;UPDATE rows &#061; &#034; &#043; updateData.getRows().size());<br \/>\n} else if (data instanceof DeleteRowsEventData) {<br \/>\nDeleteRowsEventData deleteData &#061; (DeleteRowsEventData) data;<br \/>\nSystem.out.println(&#034;DELETE rows &#061; &#034; &#043; deleteData.getRows().size());<br \/>\n}<br \/>\n});<br \/>\nclient.connect();<br \/>\n}<br \/>\n}<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u89e3\u6790\u5b57\u6bb5\u540d\u4e0e\u8868\u7ed3\u6784\u3002\u4e8b\u4ef6\u4e2d\u7684\u884c\u6570\u636e\u9ed8\u8ba4\u4ee5 Object[] \u65b9\u5f0f\u8fd4\u56de&#xff0c;\u4e0b\u6807\u4e0e\u8868\u7684\u5217\u987a\u5e8f\u5bf9\u5e94\u3002\u5982\u679c\u8981\u8fd8\u539f\u5b57\u6bb5\u540d&#xff0c;\u9700\u8981\u67e5\u8be2 information_schema \u83b7\u53d6\u8868\u7ed3\u6784&#xff0c;\u6216\u8005\u4f7f\u7528 TableMapEventData \u4e2d\u7684\u8868\u4fe1\u606f\u3002\u751f\u4ea7\u73af\u5883\u4e2d\u901a\u5e38\u7ed3\u5408\u7f13\u5b58\u673a\u5236&#xff0c;\u907f\u514d\u6bcf\u6b21\u4e8b\u4ef6\u90fd\u67e5\u5143\u6570\u636e\u3002<\/p>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u5904\u7406\u4f4d\u70b9\u4fdd\u5b58\u3002\u5b9e\u65f6\u540c\u6b65\u7cfb\u7edf\u5fc5\u987b\u5728\u6d88\u8d39\u6210\u529f\u540e\u4fdd\u5b58 Binlog \u6587\u4ef6\u540d\u4e0e position&#xff08;\u5373 offset&#xff09;&#xff0c;\u4ee5\u4fbf\u91cd\u542f\u540e\u65ad\u70b9\u7eed\u4f20\u3002\u53ef\u4ee5\u901a\u8fc7 Event \u7684 header \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u7684 position&#xff0c;\u5e76\u843d\u76d8\u5230\u672c\u5730\u6587\u4ef6\u6216 Kafka offset \u4e2d\u3002<\/p>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;\u81ea\u7814\u89e3\u6790\u5668\u9700\u8981\u5904\u7406\u7684\u7ec6\u8282\u8f83\u591a&#xff0c;\u5305\u62ec\u8fde\u63a5\u9274\u6743\u3001\u534a\u540c\u6b65\u590d\u5236\u3001\u5927\u4e8b\u52a1\u62c6\u89e3\u3001\u5b57\u6bb5\u7c7b\u578b\u6620\u5c04&#xff08;\u5c24\u5176\u662f DATETIME\u3001DECIMAL\u3001BIT&#xff09;\u3001\u4ee5\u53ca\u5f02\u5e38\u91cd\u8fde\u540e\u7684\u4f4d\u70b9\u6062\u590d\u3002\u9664\u975e\u56e2\u961f\u6709\u5f88\u5f3a\u7684\u5b9a\u5236\u9700\u6c42&#xff0c;\u5426\u5219\u4f18\u5148\u9009\u7528\u6210\u719f\u7684 Canal \/ Maxwell \/ Debezium \u800c\u975e\u76f4\u63a5\u88f8\u5199\u3002<\/p>\n<h3>\u4e03\u3001Binlog \u89e3\u6790\u7684\u6027\u80fd\u4f18\u5316\u4e0e\u6ce8\u610f\u4e8b\u9879<\/h3>\n<p>\u5728\u5b9e\u9645\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;Binlog \u89e3\u6790\u4f1a\u9762\u4e34\u65e5\u5fd7\u91cf\u5927\u3001\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8\u3001\u8d44\u6e90\u6d88\u8017\u7b49\u591a\u91cd\u538b\u529b&#xff0c;\u4ee5\u4e0b\u7ecf\u9a8c\u503c\u5f97\u91cd\u89c6\u3002<\/p>\n<h4>7.1 \u63a7\u5236 Binlog \u4f53\u79ef<\/h4>\n<ul>\n<li>\u4f18\u5148\u4f7f\u7528 ROW \u683c\u5f0f&#xff0c;\u4f46\u6309\u9700\u8bbe\u7f6e binlog_row_image\u3002\u5982\u679c\u4e0d\u9700\u8981\u5b8c\u6574\u5ba1\u8ba1&#xff0c;\u53ef\u8bbe\u7f6e MINIMAL \u51cf\u5c11\u65e5\u5fd7\u91cf\u3002<\/li>\n<li>\u8bbe\u7f6e\u5408\u7406\u7684 expire_logs_days&#xff0c;\u907f\u514d Binlog \u65e0\u9650\u81a8\u80c0\u8017\u5c3d\u78c1\u76d8&#xff0c;\u540c\u65f6\u4e0e\u5907\u4efd\u7b56\u7565\u5bf9\u9f50&#xff0c;\u4fdd\u8bc1\u53ef\u6062\u590d\u7a97\u53e3\u3002<\/li>\n<li>\u907f\u514d\u9891\u7e41\u65e0\u8c13\u7684\u5c0f\u4e8b\u52a1&#xff0c;\u6279\u91cf\u64cd\u4f5c\u80fd\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u964d\u4f4e\u6bcf\u884c\u53d8\u66f4\u7684\u5e73\u5747\u65e5\u5fd7\u5f00\u9500\u3002<\/li>\n<li>\u5bf9\u5927\u8868\u505a DDL \u6216\u6279\u91cf UPDATE \u65f6&#xff0c;\u63d0\u524d\u8bc4\u4f30 Binlog \u589e\u91cf&#xff0c;\u5fc5\u8981\u65f6\u9519\u5cf0\u6267\u884c\u3002<\/li>\n<\/ul>\n<h4>7.2 \u89e3\u6790\u4fa7\u4f18\u5316<\/h4>\n<ul>\n<li>\u8fdc\u7a0b\u62c9\u53d6 Binlog \u4f1a\u589e\u52a0\u4e3b\u5e93\u7f51\u7edc\u548c CPU \u538b\u529b&#xff0c;\u5efa\u8bae\u4f7f\u7528\u72ec\u7acb\u7684 Binlog \u8ba2\u9605\u8d26\u53f7&#xff0c;\u5e76\u5c3d\u91cf\u5728\u4ece\u5e93\u6216\u4e13\u95e8\u7684\u89e3\u6790\u673a\u4e0a\u6d88\u8d39\u3002<\/li>\n<li>\u4f7f\u7528\u6d41\u5f0f\u89e3\u6790\u800c\u975e\u4e00\u6b21\u6027\u52a0\u8f7d\u5927\u6587\u4ef6&#xff0c;\u964d\u4f4e\u5185\u5b58\u5cf0\u503c\u3002<\/li>\n<li>\u6309 position \u800c\u975e\u65f6\u95f4\u8fc7\u6ee4&#xff0c;position \u662f\u5b57\u8282\u7cbe\u786e\u7684&#xff0c;\u65f6\u95f4\u5219\u53ef\u80fd\u56e0\u79d2\u7ea7\u7cbe\u5ea6\u5bfc\u81f4\u8fb9\u754c\u95ee\u9898\u3002<\/li>\n<li>\u89e3\u6790\u7ed3\u679c\u9700\u8981\u6301\u4e45\u5316\u65f6&#xff0c;\u6279\u91cf\u5199\u5165\u4e0b\u6e38&#xff0c;\u51cf\u5c11\u5c0f IO \u6b21\u6570\u3002<\/li>\n<\/ul>\n<h4>7.3 \u5b89\u5168\u4e0e\u89c4\u8303<\/h4>\n<ul>\n<li>Binlog \u5305\u542b\u5b8c\u6574\u4e1a\u52a1\u6570\u636e&#xff0c;\u5c5e\u4e8e\u654f\u611f\u4fe1\u606f&#xff0c;\u6587\u4ef6\u4e0e\u89e3\u6790\u7ed3\u679c\u90fd\u8981\u4e25\u683c\u63a7\u5236\u8bbf\u95ee\u6743\u9650&#xff0c;\u4f20\u8f93\u8fc7\u7a0b\u52a0\u5bc6\u3002<\/li>\n<li>\u590d\u5236\u8d26\u53f7\u4ec5\u6388\u4e88 REPLICATION SLAVE\u3001REPLICATION CLIENT \u548c\u5fc5\u8981\u7684 SELECT \u6743\u9650&#xff0c;\u4e0d\u6388\u4e88\u5199\u6743\u9650&#xff0c;\u6700\u5c0f\u5316\u653b\u51fb\u9762\u3002<\/li>\n<li>\u6062\u590d\u64cd\u4f5c\u524d\u5148\u5907\u4efd\u73b0\u72b6&#xff0c;\u6267\u884c\u56de\u6eda\/\u6062\u590d\u540e\u7acb\u5373\u6821\u9a8c&#xff0c;\u5e76\u4fdd\u7559\u539f\u59cb Binlog \u6587\u4ef6\u5907\u67e5\u3002<\/li>\n<\/ul>\n<h3>\u516b\u3001\u5e38\u89c1\u95ee\u9898\u6392\u67e5\u624b\u518c<\/h3>\n<p>\u4ee5\u4e0b\u662f Binlog \u89e3\u6790\u76f8\u5173\u7684\u9ad8\u9891\u95ee\u9898\u53ca\u5bf9\u5e94\u5904\u7406\u601d\u8def&#xff0c;\u4fbf\u4e8e\u5feb\u901f\u67e5\u9605\u3002<\/p>\n<table>\n<tr>\u95ee\u9898\u73b0\u8c61\u53ef\u80fd\u539f\u56e0\u6392\u67e5\u4e0e\u5904\u7406<\/tr>\n<tbody>\n<tr>\n<td>SHOW VARIABLES LIKE &#039;log_bin&#039; \u8fd4\u56de OFF<\/td>\n<td>\u672a\u5728\u914d\u7f6e\u4e2d\u5f00\u542f Binlog&#xff0c;\u6216\u7f3a\u5c11 server-id<\/td>\n<td>\u4fee\u6539 my.cnf \u589e\u52a0 log_bin \u4e0e server-id&#xff0c;\u91cd\u542f\u540e\u786e\u8ba4<\/td>\n<\/tr>\n<tr>\n<td>ROW \u4e8b\u4ef6\u663e\u793a base64 \u4e71\u7801<\/td>\n<td>\u672a\u52a0\u89e3\u7801\u53c2\u6570<\/td>\n<td>\u4f7f\u7528 &#8211;base64-output&#061;DECODE-ROWS -v<\/td>\n<\/tr>\n<tr>\n<td>\u6309 &#8211;database \u8fc7\u6ee4\u6ca1\u6709\u6548\u679c<\/td>\n<td>-d \u53ea\u8fc7\u6ee4\u9ed8\u8ba4\u5e93&#xff0c;\u8de8\u5e93\/\u5168\u9650\u5b9a\u540d\u573a\u666f\u4e0d\u53ef\u9760<\/td>\n<td>\u7ed3\u5408 &#8211;tables \u6216\u6539\u7528\u7f16\u7a0b\u5f0f\u89e3\u6790\u540e\u8fc7\u6ee4<\/td>\n<\/tr>\n<tr>\n<td>\u6062\u590d\u65f6\u90e8\u5206\u884c\u65e0\u6cd5\u8fd8\u539f<\/td>\n<td>binlog_row_image&#061;MINIMAL \u7f3a\u5c11\u5b8c\u6574\u524d\u540e\u503c<\/td>\n<td>\u751f\u4ea7\u5e93\u6539\u4e3a FULL&#xff0c;\u7f3a\u5931\u90e8\u5206\u53ea\u80fd\u501f\u52a9\u5907\u4efd<\/td>\n<\/tr>\n<tr>\n<td>\u4e3b\u4ece\u590d\u5236 SQL \u7ebf\u7a0b\u62a5\u4e3b\u952e\u51b2\u7a81<\/td>\n<td>\u4ece\u5e93\u88ab\u624b\u5de5\u5199\u5165&#xff0c;\u6216\u4e3b\u4ece\u6570\u636e\u5df2\u5206\u53c9<\/td>\n<td>\u89e3\u6790\u51fa\u9519\u4e8b\u4ef6\u786e\u8ba4\u51b2\u7a81\u6570\u636e&#xff0c;\u8c28\u614e\u8df3\u8fc7\u6216\u91cd\u5efa\u4ece\u5e93<\/td>\n<\/tr>\n<tr>\n<td>Canal \u8fde\u63a5\u4e0d\u4e0a MySQL<\/td>\n<td>\u8d26\u53f7\u6743\u9650\u4e0d\u8db3\u6216 Binlog \u672a\u5f00\u542f<\/td>\n<td>\u68c0\u67e5 REPLICATION \u6743\u9650\u3001log_bin\u3001server-id<\/td>\n<\/tr>\n<tr>\n<td>\u95ea\u56de\u751f\u6210\u7684 SQL \u6267\u884c\u540e\u6570\u636e\u4e0d\u5bf9<\/td>\n<td>\u8bef\u64cd\u4f5c\u540e\u8be5\u884c\u53c8\u88ab\u5176\u4ed6\u4e8b\u52a1\u4fee\u6539<\/td>\n<td>\u5c3d\u5feb\u6267\u884c\u95ea\u56de&#xff0c;\u68c0\u67e5\u5e76\u53d1\u5199\u5165&#xff0c;\u5fc5\u8981\u65f6\u4eba\u5de5\u4ecb\u5165<\/td>\n<\/tr>\n<tr>\n<td>Binlog \u6587\u4ef6\u8fc7\u591a\u5360\u7528\u78c1\u76d8<\/td>\n<td>\u8fc7\u671f\u7b56\u7565\u672a\u751f\u6548\u6216\u8bbe\u7f6e\u8fc7\u957f<\/td>\n<td>\u68c0\u67e5 expire_logs_days \/ binlog_expire_logs_seconds<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<p>Binlog \u662f MySQL \u6570\u636e\u57fa\u7840\u8bbe\u65bd\u4e2d\u6700\u91cd\u8981\u3001\u4e5f\u6700\u5bb9\u6613\u88ab\u4f4e\u4f30\u7684\u7ec4\u4ef6\u4e4b\u4e00\u3002\u5b83\u65e2\u627f\u8f7d\u7740\u4e3b\u4ece\u590d\u5236\u7684\u4e00\u81f4\u6027&#xff0c;\u4e5f\u4e3a\u6570\u636e\u6062\u590d\u3001\u5ba1\u8ba1\u5408\u89c4\u3001\u5b9e\u65f6\u540c\u6b65\u548c\u8bef\u64cd\u4f5c\u56de\u6eda\u63d0\u4f9b\u4e86\u5e95\u5c42\u652f\u6491\u3002\u672c\u6587\u4ece Binlog \u7684\u57fa\u672c\u6982\u5ff5\u4e0e\u4e09\u79cd\u683c\u5f0f\u8bb2\u8d77&#xff0c;\u8be6\u7ec6\u68b3\u7406\u4e86 mysqlbinlog \u7684\u5e38\u7528\u89e3\u6790\u65b9\u6cd5&#xff0c;\u5e76\u56f4\u7ed5\u8bef\u5220\u6062\u590d\u3001\u4e3b\u4ece\u6392\u67e5\u3001\u53d8\u66f4\u5ba1\u8ba1\u3001\u589e\u91cf\u540c\u6b65\u3001\u95ea\u56de\u56de\u6eda 5 \u79cd\u5178\u578b\u573a\u666f\u7ed9\u51fa\u4e86\u53ef\u843d\u5730\u7684\u5b9e\u64cd\u6b65\u9aa4&#xff0c;\u6700\u540e\u8865\u5145\u4e86\u7f16\u7a0b\u89e3\u6790\u4e0e\u6027\u80fd\u4f18\u5316\u5efa\u8bae\u3002<\/p>\n<p>\u638c\u63e1 Binlog \u89e3\u6790&#xff0c;\u6838\u5fc3\u5728\u4e8e\u4e09\u70b9&#xff1a;\u4e00\u662f\u7406\u89e3 ROW \u683c\u5f0f\u4e8b\u4ef6\u7684\u524d\u540e\u955c\u50cf\u8bed\u4e49&#xff1b;\u4e8c\u662f\u719f\u7ec3\u8fd0\u7528 position \u4e0e\u65f6\u95f4\u8303\u56f4\u9501\u5b9a\u76ee\u6807\u4e8b\u4ef6&#xff1b;\u4e09\u662f\u5728\u5e94\u6025\u6062\u590d\u65f6\u9075\u5faa\u201c\u5148\u5907\u4efd\u3001\u518d\u64cd\u4f5c\u3001\u540e\u6821\u9a8c\u201d\u7684\u539f\u5219\u3002\u53ea\u6709\u628a\u57fa\u7840\u539f\u7406\u3001\u5de5\u5177\u80fd\u529b\u548c\u5de5\u7a0b\u89c4\u8303\u7ed3\u5408\u8d77\u6765&#xff0c;\u624d\u80fd\u5728\u9762\u5bf9\u8bef\u5220\u3001\u590d\u5236\u6545\u969c\u6216\u6570\u636e\u540c\u6b65\u9700\u6c42\u65f6\u4ece\u5bb9\u4e0d\u8feb\u3002<\/p>\n<p>\u5e0c\u671b\u8fd9\u4efd\u653b\u7565\u80fd\u591f\u6210\u4e3a\u4f60\u65e5\u5e38\u5de5\u4f5c\u4e2d\u7684\u4e00\u5f20\u201cBinlog \u89e3\u6790\u5730\u56fe\u201d\u3002\u9047\u5230\u5177\u4f53\u95ee\u9898\u65f6&#xff0c;\u56de\u5230\u5bf9\u5e94\u7684\u573a\u666f\u7ae0\u8282\u6309\u6b65\u9aa4\u6267\u884c&#xff0c;\u901a\u5e38\u80fd\u5feb\u901f\u627e\u5230\u7b54\u6848\u3002\u5982\u679c\u4f60\u6240\u5728\u56e2\u961f\u6b63\u5728\u5efa\u8bbe\u6570\u636e\u540c\u6b65\u6216\u5ba1\u8ba1\u4f53\u7cfb&#xff0c;\u4e5f\u6b22\u8fce\u628a\u672c\u6587\u4f5c\u4e3a\u6280\u672f\u9009\u578b\u4e0e\u5b9e\u65bd\u7684\u53c2\u8003\u57fa\u7ebf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Binlog \u662f\u4ec0\u4e48&#xff1f;\u4e3a\u4ec0\u4e48\u9700\u8981\u89e3\u6790\u5b83&#xff1f;Binlog&#xff0c;\u5168\u79f0 Binary Log&#xff08;\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff09;&#xff0c;\u662f MySQL Server \u5c42\u4ea7\u751f\u7684\u4e00\u79cd\u903b\u8f91\u65e5\u5fd7&#xff0c;\u7528\u4e8e\u8bb0\u5f55\u6240\u6709\u53ef\u80fd\u5f15\u8d77\u6570\u636e\u53d8\u66f4\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u5b83\u4e0e InnoDB \u7684 redo log\u3001undo log \u4e0d\u540c&#xff1a;redo log \u548c undo log \u662f\u5b58\u50a8\u5f15\u64ce\u5c42\u7684\u7269\u7406\/\u903b\u8f91\u65e5\u5fd7&#xff0c;\u800c Binlog \u662f\u4e0a\u5c42<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[116,114,100],"topic":[],"class_list":["post-100868","post","type-post","status-publish","format-standard","hentry","category-server","tag-adb","tag-mysql","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/100868.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001Binlog \u662f\u4ec0\u4e48&#xff1f;\u4e3a\u4ec0\u4e48\u9700\u8981\u89e3\u6790\u5b83&#xff1f;Binlog&#xff0c;\u5168\u79f0 Binary Log&#xff08;\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff09;&#xff0c;\u662f MySQL Server \u5c42\u4ea7\u751f\u7684\u4e00\u79cd\u903b\u8f91\u65e5\u5fd7&#xff0c;\u7528\u4e8e\u8bb0\u5f55\u6240\u6709\u53ef\u80fd\u5f15\u8d77\u6570\u636e\u53d8\u66f4\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u5b83\u4e0e InnoDB \u7684 redo log\u3001undo log \u4e0d\u540c&#xff1a;redo log \u548c undo log \u662f\u5b58\u50a8\u5f15\u64ce\u5c42\u7684\u7269\u7406\/\u903b\u8f91\u65e5\u5fd7&#xff0c;\u800c Binlog \u662f\u4e0a\u5c42\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/100868.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-05T06:17:09+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/100868.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/100868.html\",\"name\":\"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-05T06:17:09+00:00\",\"dateModified\":\"2026-09-05T06:17:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/100868.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/100868.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/100868.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/100868.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001Binlog \u662f\u4ec0\u4e48&#xff1f;\u4e3a\u4ec0\u4e48\u9700\u8981\u89e3\u6790\u5b83&#xff1f;Binlog&#xff0c;\u5168\u79f0 Binary Log&#xff08;\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff09;&#xff0c;\u662f MySQL Server \u5c42\u4ea7\u751f\u7684\u4e00\u79cd\u903b\u8f91\u65e5\u5fd7&#xff0c;\u7528\u4e8e\u8bb0\u5f55\u6240\u6709\u53ef\u80fd\u5f15\u8d77\u6570\u636e\u53d8\u66f4\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u5b83\u4e0e InnoDB \u7684 redo log\u3001undo log \u4e0d\u540c&#xff1a;redo log \u548c undo log \u662f\u5b58\u50a8\u5f15\u64ce\u5c42\u7684\u7269\u7406\/\u903b\u8f91\u65e5\u5fd7&#xff0c;\u800c Binlog \u662f\u4e0a\u5c42","og_url":"https:\/\/www.wsisp.com\/helps\/100868.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-05T06:17:09+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/100868.html","url":"https:\/\/www.wsisp.com\/helps\/100868.html","name":"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-05T06:17:09+00:00","dateModified":"2026-09-05T06:17:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/100868.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/100868.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/100868.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010MySQL\u3011Binlog\u89e3\u6790\u5168\u653b\u7565\uff1a5\u79cd\u573a\u666f+\u5b9e\u64cd\u6b65\u9aa4"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/100868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=100868"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/100868\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=100868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=100868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=100868"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=100868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}