乐趣区

CanalAdmin-集群环境配置及踩坑实录

集群配置

canal-admin的安装不再累述,可翻看之前文章,本文主要记录 canal-admin 集群环境的配置和踩坑记录

新建集群

填写 zk 的集群信息

修改集群配置参数

主要参数说明

canal 持久化数据到 zookeeper 上的更新频率

canal.file.flush.period = 1000

memory store RingBuffer size, should be Math.pow(2,n)

canal.instance.memory.buffer.size = 16384

memory store RingBuffer used memory unit size , default 1kb

canal.instance.memory.buffer.memunit = 1024

meory store gets mode used MEMSIZE or ITEMSIZE

canal.instance.memory.batch.mode = MEMSIZE
canal.instance.memory.rawEntry = true

是否开启心跳检查

canal.instance.detecting.enable = false

心跳检查 sql

canal.instance.detecting.sql = select 1

心跳检查频率

canal.instance.detecting.interval.time = 3

心跳检查失败重试次数

canal.instance.detecting.retry.threshold = 3

心跳检查失败后,是否开启自动 mysql 自动切换,mysql 主从地址可在具体 instance 中配置

canal.instance.detecting.heartbeatHaEnable = false

support maximum transaction size, more than the size of the transaction will be cut into multiple transactions delivery

canal.instance.transaction.size = 1024

mysql fallback connected to new master should fallback times

canal.instance.fallbackIntervalInSeconds = 60

network config 网络相关配置

canal.instance.network.receiveBufferSize = 16384
canal.instance.network.sendBufferSize = 16384
canal.instance.network.soTimeout = 30

binlog filter config

canal.instance.filter.druid.ddl = true

忽略 dcl

canal.instance.filter.query.dcl = true
canal.instance.filter.query.dml = false

忽略 ddl

canal.instance.filter.query.ddl = true

是否忽略 binlog 表结构获取失败的异常

canal.instance.filter.table.error = false
canal.instance.filter.rows = false
canal.instance.filter.transaction.entry = false

binlog format/image check

canal.instance.binlog.format = ROW,STATEMENT,MIXED
canal.instance.binlog.image = FULL,MINIMAL,NOBLOB

binlog ddl isolation

canal.instance.get.ddl.isolation = false

parallel parser config 开启 binlog 并行解析模式

canal.instance.parser.parallel = true

concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors()

canal.instance.parser.parallelThreadSize = 16

disruptor ringbuffer size, must be power of 2

canal.instance.parser.parallelBufferSize = 256

instance 地址配置,不写默认扫描 conf 目录下所有 instance 配置

canal.destinations =
canal.conf.dir = ../conf
canal.auto.scan = true
canal.auto.scan.interval = 5

持久化的方式主要是写入 zookeeper,保证数据集群共享

canal.instance.global.spring.xml = classpath:spring/default-instance.xml

mq 地址

canal.mq.servers = 192.168.199.122:9092,192.168.199.123:9092,192.168.199.124:9092

重试次数

canal.mq.retries = 3

批处理大小

canal.mq.batchSize = 16384
canal.mq.maxRequestSize = 1048576

延时时间

canal.mq.lingerMs = 100
canal.mq.bufferMemory = 33554432

获取 canal 数据的批次大小

canal.mq.canalBatchSize = 50

获取 canal 数据的超时时间

canal.mq.canalGetTimeout = 100

ture 代表 json 格式

canal.mq.flatMessage = true

不启动数据压缩

canal.mq.compressionType = none

主副全部成功才 ack

canal.mq.acks = all

canal.mq.properties. =

canal.mq.producerGroup = test

Set this value to “cloud”, if you want open message trace feature in aliyun.

canal.mq.accessChannel = local

新建 Server

在各个节点运行 sh bin/startup.sh local
Server列表即可看到启动了三个canal-server

新建 Instance

新建Instance,主要配置参数

只同步 test 数据库的 sc_test 表,.*\\..*代表同步所有表

canal.instance.filter.regex=test\.sc_test

mq topic 名称

canal.mq.topic=wcc-scm

由于我们项目需要保证数据的顺序性,使用单 topic 单分区配置,性能会下降,消费者 QPS:2-3k,对我们项目来说也是足够的了

canal.mq.partition=0

踩的坑

由于我们使用的是阿里云的 RDS 数据库,阿里云 RDS 是自动清理 binlog,会导致canal 读取 binlog 失败
java.io.IOException: Received error packet: errno = 1236, sqlstate = HY000 errmsg = Could not find first log file name in binary log index file
可将 binlog 文件上传阿里云 OSS 服务器,在 instance 配置中新增
` canal.instance.rds.accesskey=
canal.instance.rds.secretkey=
canal.instance.rds.instanceId=`
吐槽下:运维点 binlog 一键上传 ` 到 OSS,没有任何提示,并没有成功,好歹给个失败原因提示啊。。。

退出移动版