Introduction to Canal - server configuration

Canal is a framework (component) provided by Alibaba for incremental log analysis of MySQL database, providing incremental data subscription and consumption.

1. Configure MySQL configuration file( my.ini ), add the following configuration:

[mysqld]
log-bin=mysql-bin #Enable log monitoring
binlog-format=ROW #Monitoring mode is ROW
server_id=1 #The configuration of MySQL replacement needs to be defined. It cannot be the same as the slave ID of canal

2. Connect to the database and execute the following statement:

[mysqld]
CREATE USER canal IDENTIFIED BY 'canal';  
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;

Note: the principle of Canal is to simulate that it is MySQL Slave, so it must be used as the related permission of MySQL Slave.

3. Configure the configuration file of Canal (conf/example/instance.properties ), add the following configuration:

#Database configuration
canal.instance.master.address = 127.0.0.1:3306
canal.instance.master.journal.name =
canal.instance.master.position =
canal.instance.master.timestamp =

#Master database
canal.instance.dbUsername = canal #accounts
canal.instance.dbPassword = canal #password
canal.instance.defaultDatabaseName = #Listening database name
canal.instance.connectionCharset = UTF-8 #character set

#Backup database (can not be configured)
#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =

4. Execute the startup file (bin/startup.bat Or bin/startup.sh ).

5. Inspection log:

logs/canal/canal.log

com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.
com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[127.0.0.1:11111]
com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......
logs/example/example.log

c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [canal.properties]
c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [example/instance.properties]
c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example 
c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful....

Tags: MySQL Database Spring

Posted on Thu, 28 May 2020 11:25:20 -0400 by jstngk