Open source component canal, read mysql binlog

1 Download canal from github, https://github.com/alibaba/canal/tree/canal-1.0.25, and mvn package.
Find the package that deploys canal in the deployer directory.
Documentation: https://github.com/alibaba/canal/wiki/Introduction (the best documentation is the official documentation)

 

 

2mysql opens the binlog log and creates the user canal.

 

3 Configure the slaveid of canal (canal simulates the slave of mysql) and the user name and password of the connection
3.1 Configure F:\canal.deployer-1.0.25\conf\example\instance.properties, mainly configure the ip and port of the connection to mysql, Username Password.

 

3.2 Configure F:\canal.deployer-1.0.25\conf\canal.properties, mainly configure canal's own properties (canal.id, canal.ip, canal.port) and the loaded spring configuration file, read database configuration file (mysql-tsdb.xml), and the location storage location configuration file (file-instance.xml or default-instance.xml).
file-instance.xml: All components (parser, sink, store) have chosen the file-based persistence mode. Note that HA mechanism is not supported; Features: Stand-alone persistence is supported; Scenario: Production environment, no high-availability cluster requirements, Simple and usable.
default-instance.xml: All components (parser, sink, store) have selected persistence mode. At present, the main way of persistence is to write to zookeeper to ensure data cluster sharing; Features: Support high-availability clusters; Scenarios : Production environment, clustered deployment ( if file-instance.xml is used, canal will generate a meta.dat file after reading binlog to record the location information currently read to binlog ).

 

4启动canal。(F:\canal.deployer-1.0.25\bin\startup.bat)

 

5java connects canal.
Refer to the API documentation of the canal component: https://github.com/alibaba/canal/wiki/ClientAPI and example examples (AbstractCanalClientTest, SimpleCanalClientTest).

 

Printed obtained binlog information

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325343887&siteId=291194637