The canal principle is relatively simple:
1) canal simulates the interactive protocol of mysql slave, pretends to be mysql slave, and sends dump protocol to mysql master
2) The mysql master receives the dump request and starts to push the binary log to the slave (that is, canal)
3) canal parses the binary log object (original is byte stream)
1. Compile
Second, modify the configuration file
Modify the configuration file
The principle of canal is based on the mysql binlog technology, so it is necessary to enable the binlog writing function of mysql here. It is recommended to configure the binlog mode as row.
[mysqld]
log-bin=mysql-bin #Add this line and it's ok
binlog-format=ROW #Select row mode
server_id=1 #Configure mysql replaction needs to be defined and cannot be duplicated with canal's slaveId
3. Start the test
1) Modify Mysql and start Mysql
2) Start canal
3 ) start the canal consumer
4. Result Verification