canal测试环境搭建

准备环境

1、 mysql安装

2、mysql开启binglog写入功能,配置binglog-format为row模式,my.cnf配置如下

[mysqld]

log-bin=mysql-bin # 开启 binlog

binlog-format=ROW # 选择 ROW 模式

server_id=1 # 配置 MySQL replaction 需要定义,不要和 canal 的 slaveId 重复

3、单独添加canal账户,并分配slave权限,命令如下

CREATE USER canal IDENTIFIED BY 'canal';  

GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';

-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;

FLUSH PRIVILEGES;

安装canal(参考官网: https://github.com/alibaba/canal/wiki/QuickStart

1、下载canal,访问https://github.com/alibaba/canal/releases,选择合适的版本

wget https://github.com/alibaba/canal/releases/download/canal-1.0.17/canal.deployer-1.0.17.tar.gz

2、解压缩

mkdir /tmp/canal

tar zxvf canal.deployer-$version.tar.gz  -C /tmp/canal

3、修改配置(即配置binglog数据消费队列,可增加多个example文件夹)

vi conf/example/instance.properties

canal.instance.master.address=mysql:port

canal.instance.dbUsername=canal

canal.instance.dbPassword=canal

canal.instance.connectionCharset = UTF-8

4、启动、关闭

#启动

sh bin/startup.sh

#关闭

sh bin/stop.sh

5、观察server和instance日志

tailf logs/canal/canal.log

tailf logs/example/example.log

 

错误记录

tailf logs/example/example.log 有以下错误日志

Can't read dir of './performance_schema/' (errno: 13 - Permission denied)

show full tables from `performance_schema` where Table_type = 'BASE TABLE'

在myslq执行:

show full tables from `performance_schema` where Table_type = 'BASE TABLE'

报错如下:

ERROR 1018 (HY000): Can't read dir of './performance_schema/' (errno: 13 - Permission denied)

原因:performance_schema 文件,对应的mysql用户没有操作权限

 

解决:

chown -R mysql:mysql /var/lib/mysql/performance_schema/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值