{"id":27187,"date":"2024-11-24T15:42:09","date_gmt":"2024-11-24T07:42:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27187\/"},"modified":"2024-11-24T15:42:09","modified_gmt":"2024-11-24T07:42:09","slug":"%e5%a6%82%e4%bd%95%e5%ae%9e%e6%97%b6%e8%8e%b7%e5%8f%96-mysql-%e6%96%b0%e5%a2%9e%e6%95%b0%e6%8d%ae%e5%b9%b6%e5%8f%91%e9%80%81%e7%9f%ad%e4%bf%a1%e9%80%9a%e7%9f%a5%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27187\/","title":{"rendered":"\u5982\u4f55\u5b9e\u65f6\u83b7\u53d6 MySQL \u65b0\u589e\u6570\u636e\u5e76\u53d1\u9001\u77ed\u4fe1\u901a\u77e5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173120712741655.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u65f6\u83b7\u53d6 MySQL \u65b0\u589e\u6570\u636e\u5e76\u53d1\u9001\u77ed\u4fe1\u901a\u77e5\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5b9e\u65f6\u83b7\u53d6 MySQL \u65b0\u589e\u6570\u636e\u5e76\u53d1\u9001\u77ed\u4fe1\u901a\u77e5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u901a\u8fc7\u5b9e\u65f6\u66f4\u65b0\u83b7\u53d6\u6570\u636e\u5e93\u65b0\u589e\u6570\u636e<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u7528\u6237\u9700\u8981\u53ca\u65f6\u83b7\u53d6 MySQL \u8868\u4e2d\u7684\u65b0\u589e\u6570\u636e\uff0c\u4ee5\u4fbf\u901a\u8fc7\u77ed\u4fe1\u53d1\u9001\u7ed9\u6307\u5b9a\u53f7\u7801\u3002\u4f20\u7edf\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u670d\u52a1\u5668\u8ba1\u5212\u4efb\u52a1\u6bcf 30 \u79d2\u8bfb\u53d6\u6570\u636e\u5e93\uff0c\u4f46\u8fd9\u4f1a\u589e\u52a0\u670d\u52a1\u5668\u8d1f\u62c5\u5e76\u5ef6\u8fdf\u83b7\u53d6\u6570\u636e\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p><strong>\u4f7f\u7528 MySQL Binary Log (Binlog) \u548c Canal<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00 MySQL \u7684 Binlog\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728 my.cnf \u6587\u4ef6\u4e2d\uff0c\u627e\u5230 binlog-do-db \u548c binlog-ignore-db \u9009\u9879\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u6307\u5b9a\u8981\u8bb0\u5f55\u7684\u6570\u636e\u5e93\u3002<\/li>\n<li>\u786e\u4fdd Binlog \u5df2\u6253\u5f00\uff0c\u5e76\u901a\u8fc7 SHOW MASTER LOGS \u547d\u4ee4\u9a8c\u8bc1\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5 Canal\uff1a<\/strong><\/p>\n<ul>\n<li>Canal \u662f\u4e00\u4e2a\u5f00\u6e90\u7ec4\u4ef6\uff0c\u7528\u4e8e\u8ba2\u9605 MySQL \u7684 Binlog\u3002<\/li>\n<li>\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Canal\uff0c\u5e76\u6309\u7167\u5176\u6587\u6863\u8fdb\u884c\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e Canal \u8ba2\u9605 Binlog\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>\u6253\u5f00 Canal \u7684\u914d\u7f6e\u6587\u4ef6 canal.properties\uff0c\u5e76\u914d\u7f6e\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<ul>\n<li>canal.destinations=example<\/li>\n<li>canal.app.destination.example.dw.dbAddress=localhost (\u6570\u636e\u5e93\u5730\u5740)<\/li>\n<li>canal.app.destination.example.dw.dbPort=3306 (\u6570\u636e\u5e93\u7aef\u53e3)<\/li>\n<li>canal.app.destination.example.dw.dbUsername=root (\u6570\u636e\u5e93\u7528\u6237\u540d)<\/li>\n<li>canal.app.destination.example.dw.dbPassword=password (\u6570\u636e\u5e93\u5bc6\u7801)<\/li>\n<li>canal.app.destination.example.dw.database= (\u8981\u8ba2\u9605\u7684\u6570\u636e\u5e93\u540d\u79f0)<\/li>\n<li>canal.app.destination.example.dw.table=tbl_name (\u8981\u8ba2\u9605\u7684\u8868\u540d\u79f0)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8 Canal \u670d\u52a1\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd0\u884c sh bin\/startup.sh \u547d\u4ee4\u542f\u52a8 Canal\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b9e\u73b0 PHP \u76d1\u542c\u5668\uff1a<\/strong><\/p>\n<ul>\n<li>\u7f16\u5199\u4e00\u4e2a PHP \u76d1\u542c\u5668\uff0c\u8fde\u63a5\u5230 Canal \u5e76\u5904\u7406 Binlog \u4e8b\u4ef6\u3002<\/li>\n<li>\u5f53\u6536\u5230\u65b0\u589e\u6570\u636e\u7684 Binlog \u4e8b\u4ef6\u65f6\uff0c\u76d1\u542c\u5668\u4f1a\u63d0\u53d6\u6570\u636e\u5e76\u53d1\u9001\u77ed\u4fe1\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u83b7\u53d6\u6570\u636e\u5e93\u65b0\u589e\u6570\u636e\u7684\u9700\u6c42\uff0c\u65e0\u9700\u4f7f\u7528\u8ba1\u5212\u4efb\u52a1\uff0c\u5e76\u4e14\u53ef\u4ee5\u51cf\u5c11\u670d\u52a1\u5668\u8d1f\u62c5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5b9e\u65f6\u83b7\u53d6 MySQL \u65b0\u589e\u6570\u636e\u5e76\u53d1\u9001\u77ed\u4fe1\u901a\u77e5\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u901a\u8fc7\u5b9e\u65f6\u66f4\u65b0\u83b7\u53d6\u6570\u636e\u5e93\u65b0\u589e\u6570\u636e \u95ee\u9898\uff1a \u7528\u6237\u9700\u8981\u53ca\u65f6\u83b7\u53d6 MySQL \u8868\u4e2d\u7684\u65b0\u589e\u6570\u636e\uff0c\u4ee5\u4fbf\u901a\u8fc7\u77ed\u4fe1\u53d1\u9001\u7ed9\u6307\u5b9a\u53f7\u7801\u3002\u4f20\u7edf\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u670d\u52a1\u5668\u8ba1\u5212\u4efb\u52a1\u6bcf 30 \u79d2\u8bfb\u53d6\u6570\u636e\u5e93\uff0c\u4f46\u8fd9\u4f1a\u589e\u52a0\u670d\u52a1\u5668\u8d1f\u62c5\u5e76\u5ef6\u8fdf\u83b7\u53d6\u6570\u636e\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u4f7f\u7528 MySQL Binary Log (Binlog) \u548c Canal \u6253\u5f00 MySQL \u7684 Binlog\uff1a \u5728 my.cnf \u6587\u4ef6\u4e2d\uff0c\u627e\u5230 binlog-do-db \u548c binlog-ignore-db \u9009\u9879\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u6307\u5b9a\u8981\u8bb0\u5f55\u7684\u6570\u636e\u5e93\u3002 \u786e\u4fdd Binlog \u5df2\u6253\u5f00\uff0c\u5e76\u901a\u8fc7 SHOW MASTER LOGS \u547d\u4ee4\u9a8c\u8bc1\u3002 \u5b89\u88c5 Canal\uff1a Canal \u662f\u4e00\u4e2a\u5f00\u6e90\u7ec4\u4ef6\uff0c\u7528\u4e8e\u8ba2\u9605 MySQL \u7684 Binlog\u3002 \u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Canal\uff0c\u5e76\u6309\u7167\u5176\u6587\u6863\u8fdb\u884c\u914d\u7f6e\u3002 \u914d\u7f6e Canal \u8ba2\u9605 Binlog\uff1a \u6253\u5f00 Canal \u7684\u914d\u7f6e\u6587\u4ef6 canal.properties\uff0c\u5e76\u914d\u7f6e\u4ee5\u4e0b\u5185\u5bb9\uff1a canal.destinations=example canal.app.destination.example.dw.dbAddress=localhost (\u6570\u636e\u5e93\u5730\u5740) canal.app.destination.example.dw.dbPort=3306 (\u6570\u636e\u5e93\u7aef\u53e3) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27187","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=27187"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27187\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}