Windows starts locally using Canal (database synchronization)

For junior and intermediate programmers, documentation can be easily understood by intermediate and advanced programmers, but it is still difficult for beginners.

Will you be asked about data synchronization during the interview? What should be used to synchronize, synchronize efficiency, synchronize consistency, etc...

First of all, you need to know some synchronization tools. This article will show you how to use Alibaba’s Canal synchronization tool.

first step

 Find the my.ini of the local mysql. Note the difference: the one on Linux is my.cnf.

714ea0c667714bb2b5b8a0a76f89d1ee.png

 The general default path is C:\ProgramData\MySQL\MySQL Server 8.0 directory

Add to

[mysqld]
log-bin=mysql-bin # 开启 binlog
binlog-format=ROW # 选择 ROW 模式
server_id=1 # 配置 MySQL replaction 需要定义,不要和 canal 的 slaveId 重复

e8ecab8b9a3641b89b125e0c74b5f898.png

 The second step is to download Canal 

  Here you need to create a mysql account

Reference documents

授权 canal 链接 MySQL 账号具有作为 MySQL slave 的权限, 如果已有账户可直接 grant

CREATE USER canal IDENTIFIED BY 'canal';  
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
赋予账户全部权限-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;

 command execution27ea62a9be2b458b8a76124048f9add3.png

Download the example package: https://github.com/alibaba/canal/releases

b6d70b8de0f44086afefa65cf11378b3.png

 90664587219a4c028c768d6ee46dee4d.png

 Then unzip it

355d0c4229fd42fd883484dec9da5e04.png

Find the instance.properties file in the conf\example directory

ee5686706ef149288e8c6788d91195c5.png

 

 Notice

jdk11 or above cannot be started. I will wait until I find a solution before updating.

Find the bin directory

.ef0c70f5a66e4d49980c02792d5e932e.png

 Start starthp.bat

212c25e7360748a5b3f9ee7e7b718336.png

 Find the log in the logs\example directory and check whether the startup is successful.

cfe3c4bd747c486097fd65915091ec85.png

 6689130f3ae7416faae96c195f345fda.png

 You can also use the command to view: type C:xxx\logs\example\example.log

bcde261b2daa4e308b91e11a5e08a399.png

 Started successfully

Then you can create data or table tests

It is mentioned here that if the canal account created is not given full permissions, it cannot add modifications and other operations and has a read-only status .

After granting permissions, no matter which database the database and tables are created in, they will be synchronized.

6e078c47b2a2465c9ae6be54f5a632f6.png

 

Have you failed in your studies?

Next articleCanal Advanced

 

Guess you like

Origin blog.csdn.net/qq_37544675/article/details/131013501