准备
[mysqld]
log-bin=mysql-bin # 开启 binlog
binlog-format=ROW # 选择 ROW 模式
授权 canal 链接 MySQL 账号具有作为 MySQL slave 的权限
CREATE USER canal IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
安装canal
cd canal
wget https://github.com/alibaba/canal/releases/download/canal-1.1.6/canal.deployer-1.1.6.tar.gz
tar -xvf canal.deployer-1.1.6.tar.gz
修改配置文件
vim /data/canal/conf/example/instance.properties
修改为数据源地址:
# position info
canal.instance.master.address=127.0.0.1:3306
# username/password
canal.instance.dbUsername=canal
canal.instance.dbPassword=canal
#过滤库表table regex
#所有库表:
canal.instance.filter.regex=.*\\..*
#只同步test库:
canal.instance.filter.regex=test\\...*
#只同步test库的t1 t2表
canal.instance.filter.regex=test.t1,test.t2
# mq config 修改topic名字
canal.mq.topic=canal_test
同步到kafka,修改相关配置项
vim /data/canal/conf/canal.properties
# tcp, kafka, rocketMQ, rabbitMQ, pulsarMQ
canal.serverMode = kafka
#kafka地址
kafka.bootstrap.servers = xxx
标签:canal,binlog,regex,instance,test,kafka
From: https://www.cnblogs.com/any-way/p/17124212.html