一、 Docker安装
略
二、 修改MySQL配置
2.1 修改my.cnf配置
对于自建 MySQL , 需要先开启 Binlog 写入功能,配置 binlog-format 为 ROW 模式,my.cnf 中配置如下
log-bin=mysql-bin # 开启 binlog
binlog-format=ROW # 选择 ROW 模式
server_id=1 # 配置 MySQL replaction 需要定义,不要和 canal 的 slaveId 重复
记得重启MySQL
2.2 新建MySQL用户
授权 canal 链接 MySQL 账号具有作为 MySQL slave 的权限, 如果已有账户可直接 grant
-- 新建用户
CREATE USER canal IDENTIFIED BY 'canal';
-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
-- 刷新权限
FLUSH PRIVILEGES;
三、 Canal Admin部署
2.1 下载镜像
#拉取 canal Admin镜像
$ docker pull canal/canal-admin:v1.1.4
2.2 启动容器
#拉取启动脚本
wget https://raw.githubusercontent.com/alibaba/canal/master/docker/run_admin.sh
#运行脚本
sh run_admin.sh -e server.port=8089 \
-e canal.adminUser=admin \
-e canal.adminPasswd=admin
#查看启动日志
$ docker logs canal-admin
DOCKER_DEPLOY_TYPE=VM
==> INIT /alidata/init/02init-sshd.sh
==> EXIT CODE: 0
==> INIT /alidata/init/fix-hosts.py
==> EXIT CODE: 0
==> INIT DEFAULT
Generating SSH1 RSA host key: [ OK ]
Starting sshd: [ OK ]
Starting crond: [ OK ]
==> INIT DONE
==> RUN /home/admin/app.sh
==> START ...
start mysql ...
Starting mysqld: [ OK ]
start mysql successful
start admin ...
start canal successful
==> START SUCCESSFUL ...
2.3 查看Canal Admin UI页面
四、 部署 Canal Server
3.1 拉取镜像
$ docker pull canal/canal-server:v1.1.4
3.2 启动容器
#拉取启动脚本
wget https://raw.githubusercontent.com/alibaba/canal/master/docker/run.sh
#运行脚本
sh run.sh -e canal.admin.manager=192.168.25.142:8089 \
-e canal.admin.port=11110 \
-e canal.admin.user=admin \
-e canal.admin.passwd=4ACFE3202A5FF5CF467898FC58AAB1D615029441
#查看容器日志
$ docker logs canal-server
DOCKER_DEPLOY_TYPE=VM
==> INIT /alidata/init/02init-sshd.sh
==> EXIT CODE: 0
==> INIT /alidata/init/fix-hosts.py
==> EXIT CODE: 0
==> INIT DEFAULT
Generating SSH1 RSA host key: [ OK ]
Starting sshd: [ OK ]
Starting crond: [ OK ]
==> INIT DONE
==> RUN /home/admin/app.sh
==> START ...
start canal ...
start canal successful
==> START SUCCESSFUL ...
3.3 查看Canal Admin
五、 新增instance实例
4.1 新增实例
4.2查看日志
注意查看有没有异常,状态为启动
说明成功
六、 Canal Client订阅消费
5.1 拉取Git代码
$ git clone https://github.com/alibaba/canal.git
5.2 启动Clinet消费服务
5.3 插入数据
5.4 查看控制台日志
来源:oschina
链接:https://my.oschina.net/u/4178242/blog/3102095