{"id":1828,"date":"2020-07-01T06:02:40","date_gmt":"2020-06-30T22:02:40","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1828"},"modified":"2020-07-01T06:02:40","modified_gmt":"2020-06-30T22:02:40","slug":"myflash-%e5%9b%9e%e6%bb%9amysql-binlog","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1828","title":{"rendered":"MyFlash \u56de\u6edamysql binlog"},"content":{"rendered":"<div>\n<div>\nMyFlash\u662f\u7531\u7f8e\u56e2\u70b9\u8bc4\u516c\u53f8\u6280\u672f\u5de5\u7a0b\u90e8\u5f00\u53d1\u7ef4\u62a4\u7684\u4e00\u4e2a\u56de\u6edaDML\u64cd\u4f5c\u7684\u5de5\u5177\u3002\u8be5\u5de5\u5177\u901a\u8fc7\u89e3\u6790v4\u7248\u672c\u7684binlog\uff0c\u5b8c\u6210\u56de\u6eda\u64cd\u4f5c\u3002\u76f8\u5bf9\u5df2\u6709\u7684\u56de\u6eda\u5de5\u5177\uff0c\u5176\u589e\u52a0\u4e86\u66f4\u591a\u7684\u8fc7\u6ee4\u9009\u9879\uff0c\u8ba9\u56de\u6eda\u66f4\u52a0\u5bb9\u6613\u3002<br \/>\n\u5b89\u88c5\uff1a<br \/>\ngit clone\u00a0<a href=\\\"https:\/\/link.jianshu.com?t=https%3A%2F%2Fgithub.com%2FMeituan-Dianping%2FMyFlash.git\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">https:\/\/github.com\/Meituan-Dianping\/MyFlash.git<\/a><br \/>\ncd\u00a0MyFlash<br \/>\ngcc -w\u00a0\u00a0`pkg-config &#8211;cflags &#8211;libs glib-2.0` source\/binlogParseGlib.c\u00a0\u00a0-o binary\/flashback<br \/>\ncd binary<br \/>\n.\/flashback &#8211;help\u00a0&#8211;\u67e5\u770b\u5e2e\u52a9<br \/>\n\u4f7f\u7528\uff1a<br \/>\n\u4e0b\u9762\u7684\u8fd9\u4e9b\u53c2\u6570\u662f\u53ef\u4ee5\u4efb\u610f\u7ec4\u5408\u7684\u3002<br \/>\n1.databaseNames<br \/>\n\u6307\u5b9a\u9700\u8981\u56de\u6eda\u7684\u6570\u636e\u5e93\u540d\u3002\u591a\u4e2a\u6570\u636e\u5e93\u53ef\u4ee5\u7528\u201c,\u201d\u9694\u5f00\u3002\u5982\u679c\u4e0d\u6307\u5b9a\u8be5\u53c2\u6570\uff0c\u76f8\u5f53\u4e8e\u6307\u5b9a\u4e86\u6240\u6709\u6570\u636e\u5e93\u3002<br \/>\n2.tableNames<br \/>\n\u6307\u5b9a\u9700\u8981\u56de\u6eda\u7684\u8868\u540d\u3002\u591a\u4e2a\u8868\u53ef\u4ee5\u7528\u201c,\u201d\u9694\u5f00\u3002\u5982\u679c\u4e0d\u6307\u5b9a\u8be5\u53c2\u6570\uff0c\u76f8\u5f53\u4e8e\u6307\u5b9a\u4e86\u6240\u6709\u8868\u3002<br \/>\n3.start-position<br \/>\n\u6307\u5b9a\u56de\u6eda\u5f00\u59cb\u7684\u4f4d\u7f6e\u3002\u5982\u4e0d\u6307\u5b9a\uff0c\u4ece\u6587\u4ef6\u7684\u5f00\u59cb\u5904\u56de\u6eda\u3002\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u6709\u6548\u7684\u4f4d\u7f6e\uff0c\u5426\u5219\u65e0\u6cd5\u56de\u6eda<br \/>\n4.stop-position<br \/>\n\u6307\u5b9a\u56de\u6eda\u7ed3\u675f\u7684\u4f4d\u7f6e\u3002\u5982\u4e0d\u6307\u5b9a\uff0c\u56de\u6eda\u5230\u6587\u4ef6\u7ed3\u5c3e\u3002\u8bf7\u6307\u5b9a\u6b63\u786e\u7684\u6709\u6548\u7684\u4f4d\u7f6e\uff0c\u5426\u5219\u65e0\u6cd5\u56de\u6eda<br \/>\n5.start-datetime<br \/>\n\u6307\u5b9a\u56de\u6eda\u7684\u5f00\u59cb\u65f6\u95f4\u3002\u6ce8\u610f\u683c\u5f0f\u5fc5\u987b\u662f %Y-%m-%d %H:%M:%S\u3002 \u5982\u4e0d\u6307\u5b9a\uff0c\u5219\u4e0d\u9650\u5b9a\u65f6\u95f4<br \/>\n6.stop-datetime<br \/>\n\u6307\u5b9a\u56de\u6eda\u7684\u7ed3\u675f\u65f6\u95f4\u3002\u6ce8\u610f\u683c\u5f0f\u5fc5\u987b\u662f %Y-%m-%d %H:%M:%S\u3002 \u5982\u4e0d\u6307\u5b9a\uff0c\u5219\u4e0d\u9650\u5b9a\u65f6\u95f4<br \/>\n7.sqlTypes<br \/>\n\u6307\u5b9a\u9700\u8981\u56de\u6eda\u7684sql\u7c7b\u578b\u3002\u76ee\u524d\u652f\u6301\u7684\u8fc7\u6ee4\u7c7b\u578b\u662fINSERT, UPDATE ,DELETE\u3002\u591a\u4e2a\u7c7b\u578b\u53ef\u4ee5\u7528\u201c,\u201d\u9694\u5f00\u3002<br \/>\n8.maxSplitSize<br \/>\n\u4e00\u65e6\u6307\u5b9a\u8be5\u53c2\u6570\uff0c\u5bf9\u6587\u4ef6\u8fdb\u884c\u56fa\u5b9a\u5c3a\u5bf8\u7684\u5206\u5272\uff08\u5355\u4f4d\u4e3aM\uff09\uff0c\u8fc7\u6ee4\u6761\u4ef6\u6709\u6548\uff0c\u4f46\u4e0d\u8fdb\u884c\u56de\u6eda\u64cd\u4f5c\u3002\u8be5\u53c2\u6570\u4e3b\u8981\u7528\u6765\u5c06\u5927\u7684binlog\u6587\u4ef6\u5207\u5272\uff0c\u9632\u6b62\u5355\u6b21\u5e94\u7528\u7684binlog\u5c3a\u5bf8\u8fc7\u5927\uff0c\u5bf9\u7ebf\u4e0a\u9020\u6210\u538b\u529b<br \/>\n9.binlogFileNames<br \/>\n\u6307\u5b9a\u9700\u8981\u56de\u6eda\u7684binlog\u6587\u4ef6\uff0c\u76ee\u524d\u53ea\u652f\u6301\u5355\u4e2a\u6587\u4ef6\uff0c\u540e\u7eed\u4f1a\u589e\u52a0\u591a\u4e2a\u6587\u4ef6\u652f\u6301<br \/>\n10.outBinlogFileNameBase<br \/>\n\u6307\u5b9a\u8f93\u51fa\u7684binlog\u6587\u4ef6\u524d\u7f00\uff0c\u5982\u4e0d\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u4e3abinlog_output_base.flashback<br \/>\n11.logLevel<br \/>\n\u4ec5\u4f9b\u5f00\u53d1\u8005\u4f7f\u7528\uff0c\u9ed8\u8ba4\u7ea7\u522b\u4e3aerror\u7ea7\u522b\u3002\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4e0d\u8981\u4fee\u6539\u8fd9\u4e2a\u7ea7\u522b\uff0c\u5426\u5219\u8f93\u51fa\u8fc7\u591a<br \/>\n12.include-gtids<br \/>\n\u6307\u5b9a\u9700\u8981\u56de\u6eda\u7684gtid,\u652f\u6301gtid\u7684\u5355\u4e2a\u548c\u8303\u56f4\u4e24\u79cd\u5f62\u5f0f\u3002<br \/>\n13.exclude-gtids<br \/>\n\u6307\u5b9a\u4e0d\u9700\u8981\u56de\u6eda\u7684gtid\uff0c\u7528\u6cd5\u540cinclude-gtids<br \/>\n\u6d4b\u8bd5\uff1a<br \/>\n\/root\/test\/MyFlash\/binary\/flashback &#8211;binlogFileNames=\/mysqllog\/mysql-bin.000011 &#8211;start-datetime=\\&#8221;2018-01-04 13:50:00\\&#8221; &#8211;stop-datetime=\\&#8221;2018-01-04 14:35:00\\&#8221; &#8211;databaseNames=test &#8211;tableNames=test_tb &#8211;sqlTypes=\\&#8217;UPDATE\\&#8217;,\\&#8217;DELETE\\&#8217; &#8211;outBinlogFileNameBase=test_tb<br \/>\nmysqlbinlog\u00a0\u00a0&#8211;no-defaults &#8211;base64-output=decode-rows -vv binlog_output_base.flashback &#8211;\u67e5\u770b\u56de\u6edasql<br \/>\nmysqlbinlog &#8211;no-defaults binlog_output_base.flashback |mysql -uroot -pyourpass &#8211;\u6267\u884c\u6062\u590d<br \/>\n\u53ef\u4ee5\u5728.bash_profile\u589e\u52a0<br \/>\nalias flashback=\\&#8221;\/root\/test\/MyFlash\/binary\/flashback\\&#8221;<br \/>\n\u4ee5\u540e\u5373\u53ef\u8fd9\u6837\u4f7f\u7528<br \/>\nflashback &#8211;binlogFileNames=\/mysqllog\/mysql-bin.000011 &#8211;start-datetime=\\&#8221;2018-01-04 13:50:00\\&#8221; &#8211;stop-datetime=\\&#8221;2018-01-04 14:35:00\\&#8221; &#8211;databaseNames=test &#8211;tableNames=test_tb &#8211;sqlTypes=\\&#8217;UPDATE\\&#8217;,\\&#8217;DELETE\\&#8217; &#8211;outBinlogFileNameBase=test_tb\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MyFlash\u662f\u7531\u7f8e\u56e2\u70b9\u8bc4\u516c\u53f8\u6280\u672f\u5de5\u7a0b\u90e8\u5f00\u53d1\u7ef4\u62a4\u7684\u4e00\u4e2a\u56de\u6edaDML\u64cd\u4f5c\u7684\u5de5\u5177\u3002\u8be5\u5de5\u5177\u901a\u8fc7\u89e3\u6790v4\u7248\u672c\u7684binlo &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1828\"> <span class=\"screen-reader-text\">MyFlash \u56de\u6edamysql binlog<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"MyFlash\u662f\u7531\u7f8e\u56e2\u70b9\u8bc4\u516c\u53f8\u6280\u672f\u5de5\u7a0b\u90e8\u5f00\u53d1\u7ef4\u62a4\u7684\u4e00\u4e2a\u56de\u6edaDML\u64cd\u4f5c\u7684\u5de5\u5177\u3002\u8be5\u5de5\u5177\u901a\u8fc7\u89e3\u6790v4\u7248\u672c\u7684binlo&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1828"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1828"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1828\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1828"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}