Canal Server+Canal Admin
一、 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部署
3.1 下载镜像
[root@nacos ~]# docker pull canal/canal-admin:v1.1.4
v1.1.4: Pulling from canal/canal-admin
1c8f9aa56c90: Pull complete
c5e21c824d1c: Pull complete
4ba7edb60123: Pull complete
6c0a775b3e51: Pull complete
ff741e81e02e: Pull complete
1532a9748c0a: Pull complete
a18427141526: Pull complete
Digest: sha256:c3ac54daae37b14ec32fb6a125dc9ceb243377dd147ac53af9f9f6cdf18aeac3
Status: Downloaded newer image for canal/canal-admin:v1.1.4
docker.io/canal/canal-admin:v1.1.4
3.2 启动容器
[root@nacos ~]# sh run_admin.sh -e server.port=8089 \
> -e canal.adminUser=admin \
> -e canal.adminPasswd=admin
docker run -d -it -h 192.168.1.118 -e server.port=8089 -e canal.adminUser=admin -e canal.adminPasswd=admin --name=canal-admin --net=host -m 1024m canal/canal-admin
Unable to find image 'canal/canal-admin:latest' locally
latest: Pulling from canal/canal-admin
1c8f9aa56c90: Already exists
c5e21c824d1c: Already exists
4ba7edb60123: Already exists
6c0a775b3e51: Already exists
789e835e240f: Pull complete
43cb563af61a: Pull complete
db2286df2f2d: Pull complete
Digest: sha256:b3b21de49922a361286e3074fb36a457dab54a6bbb545234a5ff8fd56a2b51fe
Status: Downloaded newer image for canal/canal-admin:latest
749993e3f7f0ace2692a839a326e9ece3654f0952984190376c5fd14c3053292
[root@nacos ~]# 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 ...
3.3 查看Canal Admin UI页面
四、 部署 Canal Server
4.1 拉取镜像
$ docker pull canal/canal-server:v1.1.4
4.2 启动容器
[root@nacos ~]# wget https://raw.githubusercontent.com/alibaba/canal/master/docker/run.sh
--2020-09-05 09:36:28-- https://raw.githubusercontent.com/alibaba/canal/master/docker/run.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.8.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.8.1c onnected.
HTTP request sent, awaiting response... 200 OK
Length: 2551 (2.5K) [text/plain]
Saving to: ‘run.sh’
100%[=========================================================================================================>] 2,551 --.-K/s in 0.08s
2020-09-05 09:37:08 (31.9 KB/s) - ‘run.sh’ saved [2551/2551]
[root@nacos ~]# sh run.sh -e canal.admin.manager=192.168.1.118:8089 -e canal.admin.port=11111 -e canal.admin.user=admin -e canal.admin.passwd=4ACFE3202A5FF5CF467898FC58AAB1D615029441
docker run -d -it -h 192.168.1.118 -e canal.admin.manager=192.168.1.118:8089 -e canal.admin.port=11111 -e canal.admin.user=admin -e canal.admin.passwd=4ACFE3202A5FF5CF467898FC58AAB1D615029441 --name=canal-server --net=host -m 4096m canal/canal-server
Unable to find image 'canal/canal-server:latest' locally
latest: Pulling from canal/canal-server
1c8f9aa56c90: Already exists
c5e21c824d1c: Already exists
4ba7edb60123: Already exists
80d8e8fac1be: Pull complete
d483624d01a8: Pull complete
8fa09556a584: Pull complete
4406c1f375ec: Pull complete
Digest: sha256:1ef8e861056b5ceb47b6aa5b8f366d96df6dfdb85835332c02c99ae45f3a9e93
Status: Downloaded newer image for canal/canal-server:latest
d7bd9031fec158cf562780ed11f9be285b83934a4240c8f834ce1809ecb9ba96
[root@nacos ~]# 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 ...
4.3 查看Canal Admin
五、 新增instance实例
5.1 新增实例
5.2查看日志
注意查看有没有异常,状态为启动
说明成功
六、 Canal Client订阅消费
https://www.cnblogs.com/dalianpai/p/13616809.html
可以查看之前的博客