Canal配置RocketMQ监听

流行的数据库中间件

安装Canal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
version: '3'
services:
mysql:
image: mysql:8
container_name: mysql-canal
environment:
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=Jiang110.
ports:
- 3336:3306
volumes:
# 数据挂载
- ./mysql/data/:/var/lib/mysql/
# 配置挂载
- ./mysql/my.cnf:/etc/my.cnf
# 初始化目录挂载
- ./mysql/init/:/docker-entrypoint-initdb.d/
command:
# 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配)
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
canal-server:
image: canal/canal-server:v1.1.5
container_name: canal-server
ports:
#canal默认端口号
- 11111:11111
environment:
#设置从库id,不能与主库id相冲突
- canal.instance.mysql.slaveId=200
- canal.instance.master.address=172.16.21.201:3336
# mysql 复制账号
- canal.instance.dbUsername=root
- canal.instance.dbPassword=Jiang110.
- canal.mq.topic=loginLogCanalTopic
- canal.instance.connectionCharset=UTF-8
#数据库名.表名
- canal.instance.filter.regex=test.user
# 指定destinations
- canal.destinations=test
# 这里配置MQ的Topic
- canal.mq.topic=test
volumes:
- /root/cancel/conf/canal.properties:/home/admin/canal-server/conf/canal.properties
- /root/cancel/logs/:/home/admin/canal-server/logs/

配置canal.properties

1
2
3
4
5
6
7
8
9
10
11
# tcp, kafka, rocketMQ, rabbitMQ
# 这个设置为rocketMQ,默认是tcp
canal.serverMode = rocketMQ

# 设置默认group
rocketmq.producer.group = test
# 默认topic
rocketmq.customized.trace.topic = test
# rocketmq的地址
rocketmq.namesrv.addr = 172.16.21.201:9876
rocketmq.vip.channel.enabled = false