canal 单节点安装
Last updated on November 22, 2024 pm
🧙 Questions
安装canal
1.1.5
☄️ Ideas
开启mysql日志
mysql 配置 默认地址 vim /etc/my.cnf (mysql –help | grep ‘my.cnf’)
sudo vim /data/mysql/conf/my.cnf
[mysqld]
log-bin=mysql-bin # 开启 binlog
binlog-format=ROW # 选择 ROW 模式
server_id=1 # 配置 MySQL replaction 需要定义,不要和 canal 的 slaveId 重复
创建canal的mysql用户
CREATE USER canal IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;
-- 查看binlog是否开启
-- log_bin | ON
SHOW VARIABLES LIKE '%bin%';
canal下载地址
https://github.com/alibaba/canal/releases
wget https://github.com/alibaba/canal/releases/download/canal-1.1.5/canal.deployer-1.1.5.tar.gz
sudo mkdir -p /data/canal/
sudo tar -zxvf canal.deployer-1.1.5.tar.gz -C /data/canal/
sudo ln -s /data/canal /opt/canal
配置canal
instance.properties 配置数据库实例
Note: 最好不要用127.0.0.1
sudo vim /opt/canal/conf/example/instance.properties
# 只保留下面的内容
#enable gtid use true/false
canal.instance.gtidon=false
# 配置mysql信息
canal.instance.master.address = 172.23.39.226:30102
canal.instance.dbUsername = root
canal.instance.dbPassword = Define123..
canal.instance.defaultDatabaseName = test
canal.instance.connectionCharset = UTF-8
# 监听哪些表
canal.instance.filter.regex=test.userinfos
# 不监听哪些表
canal.instance.filter.black.regex=mysql\\.slave_.*
# kafka信息
canal.mq.topic=test-topic
canal.mq.partition=0
canal.properties
kafka不要使用127.0.0.1 最好使用内网ip
sudo vim /opt/canal/conf/canal.properties
# canal.instance.binlog.format = ROW,STATEMENT,MIXED
# canal.instance.binlog.format = ROW
# canal.instance.binlog.image = FULL,MINIMAL,NOBLOB
# canal.instance.binlog.image = FULL
canal.serverMode = kafka
kafka.bootstrap.servers = 172.23.39.226:30120
启动 canal
停止 sudo sh bin/stop.sh
cd /opt/canal/
sudo sh bin/startup.sh
sudo netstat -nlpt| grep 11110
查看日志
# 查看canal日志
tail -f /opt/canal/logs/canal/canal.log
# 查看实例日志
tail -f /opt/canal/logs/example/example.log
🔗 Links
canal 单节点安装
https://ispong.isxcode.com/hadoop/canal/canal 单节点安装/