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.
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 重复
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 execution
Download the example package: https://github.com/alibaba/canal/releases
Then unzip it
Find the instance.properties file in the conf\example directory
Notice
jdk11 or above cannot be started. I will wait until I find a solution before updating.
Find the bin directory
.
Start starthp.bat
Find the log in the logs\example directory and check whether the startup is successful.
You can also use the command to view: type C:xxx\logs\example\example.log
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.
Have you failed in your studies?
Next articleCanal Advanced