Canal is an incremental log resolution for MySQL database provided by Ali, which provides a framework (component) for incremental data subscription and consumption.
1. Configure the MySQL configuration file (my.ini), and 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), and 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....