data
# # # https://github.com/alibaba/canal official document page https://github.com/alibaba/canal/wiki server set up document https://github.com/alibaba/canal/wiki/QuickStartCopy the code
1. Enable binlog for mysql
Mysql my.cnf configuration added the following configuration, enable binlog
[mysqld] log-bin=mysql-bin # enable binlog binlog-format=ROW # select ROW mode server_id=1 Do not repeat with Canal's slaveIdCopy the code
Added user for slave masquerading as mysql on canal server
CREATE USER canal IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;
Copy the code
After the user is created and instance example is configured, two errors are reported in the log. The first error is that too Manny connections are too many, causing the connection pool to overflow. Caching_sha2_password Auth failed
- Too many connections cause connection overflow solution:
Change the default maximum number of connections for mysql
https://mp.weixin.qq.com/s?__biz=MzA4NzQ0Njc4Ng==&mid=2247499002&idx=2&sn=54d964eb3c85bc49d3e4eaaf0045ba34&chksm=903bf89 7a74c71811c2cf5777fef1fd84c5a80887995025a41ba08d36336916fd7dd11c85801&scene=132#wechat_redirectCopy the code
- Caching_sha2_password Auth failed solution
https://www.jianshu.com/p/efa68e05d2ed
Copy the code
The password encryption mode is caching_sha2_password, so change it to mysql_native_password and update the password
ALTER USER 'canal'@'%' IDENTIFIED WITH mysql_native_password BY 'canal.. '; Update user password "FLUSH PRIVILEGES"; # refresh permissionCopy the code
2. Download canal1.1.4
Download the canal.deployer-1.1.4.tar.gz file
https://github.com/alibaba/canal/releases/tag/canal-1.1.4
Copy the code
Upload the downloaded file canal.deployer-1.1.4.tar.gz to the server and decompress it
mkdir /data/canal/canal
tar zxvf canal.deployer-$version.tar.gz -C /data/canal/canal
Copy the code
3. Modify the configuration file
cd /data/canal/canal/
vi conf/example/instance.properties
Copy the code
The parts that need to be modified are listed in the comments below
# # # mysql serverId need to modify, to guarantee the uniqueness canal. The instance. The mysql. SlaveId = 1234 # position info, Need to own the database information canal. Instance. Master. Address = 192.168.56.102:13306 canal. The instance. The master. The journal. The name = canal.instance.master.position = canal.instance.master.timestamp = #canal.instance.standby.address = #canal.instance.standby.journal.name = #canal.instance.standby.position = #canal.instance.standby.timestamp = # username/password. Need to own the database information canal. Instance. DbUsername = canal canal. The instance. The dbPassword = canal canal. Instance. DefaultDatabaseName = canal.instance.connectionCharset = UTF-8 #table regex canal.instance.filter.regex = .\*\\\\.. A \ *Copy the code
4. Start the server
Activation:
sh bin/startup.sh
Copy the code
Query server logs:
tail -50f logs/canal/canal.log
Copy the code
View instance logs:
tail -50f logs/example/example.log
Copy the code
To close:
sh bin/stop.sh
Copy the code
5. Springboot2.1.7 integrates with Canal
Refer to the official website, according to the situation of their own company can be encapsulated
https://github.com/alibaba/canal/wiki/ClientExample
Copy the code