1. Briefly introduce Canal
Canal Introduction: https://github.com/alibaba/canal/wiki/ Introduction
Canal Server: This program is the official Canal provider.
Canal Client: This program needs to be developed by itself to receive Canal data (this case uses Java code as an example).
The cluster mounting process is as follows:
- Start 2 Canal Servers at the same time, only one Canal Server and one Canal Client can run, and all of them are blocking and waiting;
- When the running Canal Server or Canal Client goes offline, the other one will be automatically mounted.
High-availability cluster implementation: Canal Server needs to configure canal.zkServers; Canal Client only needs to configure canal.zk.address.
Two, MySQL opens Binlog synchronization
Refer to the official document: https://github.com/alibaba/canal/wiki/QuickStart's [Preparation] chapter.
Three, Zookeeper preparation
Canal is discovered and registered with Zookeeper as a service, so a Zookeeper must be installed to achieve clustering.
Download address of Zookeeper ( Note: Be sure to download the apache-zookeeper-3.5.5-bin.tar.gz package ): https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.5.5/ apache-zookeeper-3.5.5-bin.tar.gz
Zookeeper UI download address:
https://github.com/DeemOpen/zkui
Four, Canal Server deployment
Refer to the official document: https://github.com/alibaba/canal/wiki/QuickStart's [Start] chapter
Step 1: Modify the configuration file
# 修改配置文件 {canal_base}/conf/canal.properties
canal.zkServers=127.0.0.1:2181
Step 2: Copy one more canal folder, and name the folder canal_slave temporarily
# 修改 {canal_slave_base}/conf/canal.properties 文件
canal.port=12111
canal.metrics.pull.port=12112
canal.zkServers=127.0.0.1:2181
Five, Canal Client deployment
Reference project: https://github.com/fomeiherz/canal-example
Step 1: Modify the configuration file
# 修改 canal-example/src/main/resources/application.properties 配置文件
server.port=9091
canal.zk.address=127.0.0.1:2181
Step 2: Copy a project, temporarily set as canal-example-slave
# 修改 canal-example-slave/src/main/resources/application.properties 配置文件
server.port=9092
canal.zk.address=127.0.0.1:2181