{"id":631,"date":"2018-03-01T14:45:57","date_gmt":"2018-03-01T06:45:57","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=631"},"modified":"2018-03-01T14:45:57","modified_gmt":"2018-03-01T06:45:57","slug":"canal%e4%bd%bf%e7%94%a8%e5%b0%8f%e7%bb%93","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=631","title":{"rendered":"Canal\u4f7f\u7528\u5c0f\u7ed3"},"content":{"rendered":"<blockquote><p>\u4e4b\u524d\u516c\u53f8\u5b58\u5728mysql\u6570\u636e\u540c\u6b65mongo\u7684\u9700\u6c42\uff0c\u53ef\u4ee5\u6709\u591a\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6bd4\u5982\u786c\u7f16\u7801\uff0c\u53d1\u9001\u6d88\u606f\u7b49\u3002\u516c\u53f8\u9009\u62e9\u7684\u662fCanal\u4e2d\u95f4\u4ef6\uff0c\u6700\u8fd1\u6709\u7a7a\u6765\u7814\u7a76\u4e0b\u4ed6\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u5bf9\u4e8emysql\u6570\u636e\u53d8\u66f4\u76d1\u542c\u6709\u9700\u6c42\u7684\u5e94\u7528\u573a\u666f\u90fd\u53ef\u4ee5\u4f7f\u7528\u5b83\u3002<\/p><\/blockquote>\n<p>\u53c2\u8003\uff1a<a class=\"uri\" href=\"https:\/\/yq.aliyun.com\/articles\/14570\">https:\/\/yq.aliyun.com\/articles\/14570<\/a><\/p>\n<ol>\n<li>Canal\u4ecb\u7ecd\n<p><a href=\"http:\/\/www.iteye.com\/topic\/1129002?spm=5176.100239.blogcont14570.5.DVxOix\">\u57fa\u4e8emysql\u6570\u636e\u5e93binlog\u7684\u589e\u91cf\u8ba2\u9605&amp;\u6d88\u8d39<\/a><\/p>\n<p>canal\u6e90\u7801\u5730\u5740\uff1a<a class=\"uri\" href=\"https:\/\/github.com\/alibaba\/canal\">https:\/\/github.com\/alibaba\/canal<\/a><\/li>\n<li>\u4e0b\u8f7d\u5b89\u88c5server\n<p>\u5148\u53bb<a class=\"uri\" href=\"https:\/\/github.com\/alibaba\/canal\/releases\">https:\/\/github.com\/alibaba\/canal\/releases<\/a>\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684canal.deployer,\u89e3\u538b\u540e\u914d\u7f6econf\/example\/instance.properties\u6587\u4ef6\u4e3a\u81ea\u5df1\u7684\u914d\u7f6e\u4e3b\u8981\u4e3a\u6570\u636e\u5e93\u7684ip\u7aef\u53e3\u548c\u8fde\u63a5\u7684\u7528\u6237\u548c\u5bc6\u7801\u3002\u8fd9\u91cc\u521b\u5efa\u4e00\u4e2arepication\u6743\u9650\u7684\u7528\u6237\u3002<\/p>\n<p><code>CREATE USER canal IDENTIFIED BY 'canal'; GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%'; -- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ; FLUSH PRIVILEGES;<\/code><\/li>\n<li>\u542f\u52a8canal server\n<p>\u6267\u884cbin\/startup.sh,\u67e5\u770b\u65e5\u5fd7logs\/canal\/canal.log\u662f\u5426\u6210\u529f\u3002<\/li>\n<li>\u542f\u52a8canal client\n<p>\u8fd9\u91cc\u4f7f\u7528\u4e0a\u9762\u6e90\u7801\u91cc\u7684SimpleCanalClientTest\u6d4b\u8bd5\u7c7b\uff08\u76f4\u8fde\u65b9\u5f0f\uff09\u3002<\/p>\n<p><code>CanalConnector connector = CanalConnectors.newSingleConnector(new InetSocketAddress(ip, 11111), destination, \"\", \"\");<\/code><br \/>\n\u8bbe\u7f6ecanal server\u7684ip\u548cport\uff0c\u8fd8\u6709\u4e00\u4e2adestination\u53c2\u6570\u3002<br \/>\ndestination\u5bf9\u5e94\u7684\u662fcanal server\u7684instance\uff0c\u9ed8\u8ba4\u662fexample\uff0c\u5b83\u4ee3\u8868\u4e00\u4e2a\u5b8c\u6574\u7684\u76d1\u542c\u5b9e\u4f8b\uff0c\u8fd9\u91cc\u5982\u679c\u6709\u591a\u4e2a\u8fde\u63a5example\u5b9e\u4f8b\u7684client\uff0c\u5219\u53ea\u6709\u4e00\u4e2aclient\u80fd\u83b7\u53d6mysql\u7684\u6570\u636e\u53d8\u66f4\u901a\u77e5\u3002\u6240\u4ee5\u8981\u60f3\u4e0d\u540c\u7684\u5e94\u7528\u90fd\u83b7\u53d6\u53d8\u66f4\u901a\u77e5\uff0c\u5219\u9700\u8981\u8fde\u63a5\u4e0d\u540c\u7684instance\uff0c\u518d\u6b64\u6211\u4eec\u53ef\u4ee5\u5728canal server\u590d\u5236\u4e00\u4e2aconf\/example\u6587\u4ef6\u5939\uff0c\u5e76\u91cd\u547d\u540d\u4e3aexample1\u5373\u53ef\u3002<\/li>\n<li>\u6d4b\u8bd5\u4ee3\u7801\n<p>\u6211\u81ea\u5df1\u8fd9\u8fb9fork\u4e86\u4ee3\u7801,\u5730\u5740:<a class=\"uri\" href=\"https:\/\/github.com\/yaojf\/canal\">https:\/\/github.com\/yaojf\/canal<\/a>\uff0c\u5e76\u4e14\u65b0\u589e\u4e86\u540c\u6b65redis\u7684\u6d4b\u8bd5\u7c7b\uff0c\u53c2\u8003\u81ea<a class=\"uri\" href=\"http:\/\/blog.csdn.net\/stubborn_cow\/article\/details\/50371405\">http:\/\/blog.csdn.net\/stubborn_cow\/article\/details\/50371405<\/a>,\u8fd0\u884cClientSample\u6d4b\u8bd5\u7c7b\u5373\u53ef\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u516c\u53f8\u5b58\u5728mysql\u6570\u636e\u540c\u6b65mongo\u7684\u9700\u6c42\uff0c\u53ef\u4ee5\u6709\u591a\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6bd4\u5982\u786c\u7f16\u7801\uff0c\u53d1\u9001\u6d88\u606f\u7b49\u3002\u516c\u53f8\u9009\u62e9\u7684\u662fCanal\u4e2d\u95f4\u4ef6\uff0c\u6700\u8fd1\u6709\u7a7a\u6765\u7814\u7a76\u4e0b\u4ed6\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u5bf9\u4e8emysql\u6570\u636e\u53d8\u66f4\u76d1\u542c\u6709\u9700\u6c42\u7684\u5e94\u7528\u573a\u666f\u90fd\u53ef\u4ee5\u4f7f\u7528\u5b83\u3002 \u53c2\u8003\uff1ahttps:\/\/yq.aliyun.com\/articles\/14570 Canal\u4ecb\u7ecd \u57fa\u4e8emysql\u6570\u636e\u5e93binlog\u7684\u589e\u91cf\u8ba2\u9605&amp;\u6d88\u8d39 canal\u6e90\u7801\u5730\u5740\uff1ahttps:\/\/github.com\/alibaba\/canal \u4e0b\u8f7d\u5b89\u88c5server \u5148\u53bbhttps:\/\/github.com\/alibaba\/canal\/releases\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684canal.deployer,\u89e3\u538b\u540e\u914d\u7f6econf\/example\/instance.properties\u6587\u4ef6\u4e3a\u81ea\u5df1\u7684\u914d\u7f6e\u4e3b\u8981\u4e3a\u6570\u636e\u5e93\u7684ip\u7aef\u53e3\u548c\u8fde\u63a5\u7684\u7528\u6237\u548c\u5bc6\u7801\u3002\u8fd9\u91cc\u521b\u5efa\u4e00\u4e2arepication\u6743\u9650\u7684\u7528\u6237\u3002 CREATE USER canal IDENTIFIED BY &#8216;canal&#8217;; GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","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":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-631","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=631"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/631\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}