{"id":1678,"date":"2023-03-25T22:32:18","date_gmt":"2023-03-25T14:32:18","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1678"},"modified":"2023-04-23T21:48:58","modified_gmt":"2023-04-23T13:48:58","slug":"alibaba-canal-server-construction","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/alibaba-canal-server-construction\/","title":{"rendered":"\u963f\u91cc\u5df4\u5df4Canal Server\u642d\u5efa"},"content":{"rendered":"<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/canal\/wiki\">https:\/\/github.com\/alibaba\/canal\/wiki<\/a><\/p>\n<h2>\u51c6\u5907<\/h2>\n<ul>\n<li>\u5bf9\u4e8e\u81ea\u5efa MySQL\uff0c\u9700\u8981\u5148\u5f00\u542f<code>Binlog<\/code>\u5199\u5165\u529f\u80fd\uff0c\u914d\u7f6e<code>binlog-format<\/code>\u4e3a<code>ROW<\/code>\u6a21\u5f0f\uff0c<code>my.cnf<\/code>\u4e2d\u914d\u7f6e\u5982\u4e0b<\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<pre><code>[mysqld]\nlog-bin=mysql-bin # \u5f00\u542f binlog\nbinlog_format=ROW # \u9009\u62e9 ROW \u6a21\u5f0f\nserver_id=1 # \u914d\u7f6e MySQL replaction \u9700\u8981\u5b9a\u4e49\uff0c\u4e0d\u8981\u548c canal \u7684 slaveId \u91cd\u590d<\/code><\/pre>\n<p>\u6ce8\u610f\uff1a\u9488\u5bf9\u963f\u91cc\u4e91 RDS for MySQL\uff0c\u9ed8\u8ba4\u6253\u5f00\u4e86<code>binlog<\/code>\uff0c\u5e76\u4e14\u8d26\u53f7\u9ed8\u8ba4\u5177\u6709<code>binlog dump<\/code>\u6743\u9650\uff0c\u4e0d\u9700\u8981\u4efb\u4f55\u6743\u9650\u6216\u8005<code>binlog<\/code>\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u76f4\u63a5\u8df3\u8fc7\u8fd9\u4e00\u6b65<br \/>\n\u6ce8\u610f\uff1a\u9488\u5bf9AWS RDS for MySQL\uff0c\u9700\u914d\u7f6e\u81ea\u5b9a\u4e49\u53c2\u6570\u7ec4<\/p>\n<ul>\n<li>\u6388\u6743<code>canal<\/code>\u8fde\u63a5 MySQL \u8d26\u53f7\u5177\u6709\u4f5c\u4e3a<code>MySQL slave<\/code>\u7684\u6743\u9650\uff0c\u5982\u679c\u5df2\u6709\u8d26\u6237\u53ef\u76f4\u63a5<code>grant<\/code><\/li>\n<\/ul>\n<pre><code class=\"language-sql\">CREATE USER canal IDENTIFIED BY &#039;canal&#039;;  \nGRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO &#039;canal&#039;@&#039;%&#039;;\n-- GRANT ALL PRIVILEGES ON *.* TO &#039;canal&#039;@&#039;%&#039; ;\nFLUSH PRIVILEGES;<\/code><\/pre>\n<h2>\u542f\u52a8<\/h2>\n<p>\uff081\uff09\u4e0b\u8f7d canal\uff0c\u8bbf\u95ee <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/canal\/releases\" title=\"release \u9875\u9762\">release \u9875\u9762<\/a>\uff0c\u9009\u62e9\u9700\u8981\u7684\u5305\u4e0b\u8f7d\uff0c\u5982\u4ee5 1.1.4 \u7248\u672c\u4e3a\u4f8b<\/p>\n<pre><code class=\"language-bash\">$ wget https:\/\/github.com\/alibaba\/canal\/releases\/download\/canal-1.1.4\/canal.deployer-1.1.4.tar.gz<\/code><\/pre>\n<p>\uff082\uff09\u89e3\u538b\u7f29<\/p>\n<pre><code class=\"language-bash\">$ mkdir \/tmp\/canal\n$ tar zxvf canal.deployer-$version.tar.gz  -C \/tmp\/canal\n# \u89e3\u538b\u5b8c\u6210\u540e\uff0c\u8fdb\u5165 \/tmp\/canal \u76ee\u5f55\uff0c\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u7ed3\u6784\ndrwxr-xr-x 2 yezhou yezhou  136 2020-02-05 21:51 bin\ndrwxr-xr-x 4 yezhou yezhou  160 2020-02-05 21:51 conf\ndrwxr-xr-x 2 yezhou yezhou 1.3K 2020-02-05 21:51 lib\ndrwxr-xr-x 2 yezhou yezhou   48 2020-02-05 21:29 logs<\/code><\/pre>\n<p>\uff083\uff09\u914d\u7f6e\u4fee\u6539<\/p>\n<pre><code class=\"language-bash\">$ vim conf\/example\/instance.properties<\/code><\/pre>\n<pre><code>## mysql serverId\ncanal.instance.mysql.slaveId = 1234\n#position info\uff0c\u9700\u8981\u6539\u6210\u81ea\u5df1\u7684\u6570\u636e\u5e93\u4fe1\u606f\ncanal.instance.master.address = 127.0.0.1:3306 \ncanal.instance.master.journal.name = \ncanal.instance.master.position = \ncanal.instance.master.timestamp = \n#canal.instance.standby.address = \n#canal.instance.standby.journal.name =\n#canal.instance.standby.position = \n#canal.instance.standby.timestamp = \n#username\/password\uff0c\u9700\u8981\u6539\u6210\u81ea\u5df1\u7684\u6570\u636e\u5e93\u4fe1\u606f\ncanal.instance.dbUsername = canal  \ncanal.instance.dbPassword = canal\ncanal.instance.defaultDatabaseName =\ncanal.instance.connectionCharset = UTF-8\n#table regex\ncanal.instance.filter.regex = .\\*\\\\\\\\..\\*<\/code><\/pre>\n<ul>\n<li><code>canal.instance.connectionCharset<\/code>\u4ee3\u8868\u6570\u636e\u5e93\u7684\u7f16\u7801\u65b9\u5f0f\u5bf9\u5e94\u5230 Java \u4e2d\u7684\u7f16\u7801\u7c7b\u578b\uff0c\u6bd4\u5982<code>UTF-8<\/code>\uff0c<code>GBK<\/code>\uff0c<code>ISO-8859-1<\/code><\/li>\n<li>\u5982\u679c\u7cfb\u7edf\u662f1\u4e2a cpu\uff0c\u9700\u8981\u5c06<code>canal.instance.parser.parallel<\/code>\u8bbe\u7f6e\u4e3a<code>false<\/code><\/li>\n<\/ul>\n<p>\uff084\uff09\u542f\u52a8<\/p>\n<pre><code class=\"language-bash\">$ sh bin\/startup.sh<\/code><\/pre>\n<p>\uff085\uff09\u67e5\u770b server \u65e5\u5fd7<\/p>\n<pre><code class=\"language-bash\">$ tail -f logs\/canal\/canal.log\n2020-02-05 22:45:27.967 [main] INFO  com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.\n2020-02-05 22:45:28.113 [main] INFO  com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[10.1.29.120:11111]\n2020-02-05 22:45:28.210 [main] INFO  com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......<\/code><\/pre>\n<p>\uff086\uff09\u67e5\u770b instance \u7684\u65e5\u5fd7<\/p>\n<pre><code class=\"language-bash\">$ tail -f logs\/example\/example.log\n2020-02-05 22:50:45.636 [main] INFO  c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [canal.properties]\n2020-02-05 22:50:45.641 [main] INFO  c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [example\/instance.properties]\n2020-02-05 22:50:45.803 [main] INFO  c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example \n2020-02-05 22:50:45.810 [main] INFO  c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful....<\/code><\/pre>\n<p>\uff087\uff09\u5173\u95ed<\/p>\n<pre><code class=\"language-bash\">$ sh bin\/stop.sh<\/code><\/pre>\n<h2>\u5176\u4ed6\u65b9\u5f0f<\/h2>\n<ul>\n<li>canal \u7684 docker \u6a21\u5f0f\u5feb\u901f\u542f\u52a8\uff0c\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/canal\/wiki\/Docker-QuickStart\" title=\"Docker QuickStart\">Docker QuickStart<\/a><\/li>\n<li>canal \u94fe\u63a5 Aliyun RDS for MySQL\uff0c\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/canal\/wiki\/aliyun-RDS-QuickStart\" title=\"Aliyun RDS QuickStart\">Aliyun RDS QuickStart<\/a><\/li>\n<li>canal \u6d88\u606f\u6295\u9012\u7ed9 kafka\/RocketMQ\uff0c\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/canal\/wiki\/Canal-Kafka-RocketMQ-QuickStart\" title=\"Canal-Kafka-RocketMQ-QuickStart\">Canal-Kafka-RocketMQ-QuickStart<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003\uff1ahttps:\/\/github.com\/alibaba\/canal\/wiki \u51c6\u5907 \u5bf9\u4e8e\u81ea\u5efa MySQL\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[417],"tags":[],"class_list":["post-1678","post","type-post","status-publish","format-standard","hentry","category-canal"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1678"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1678\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}