Detailed explanation of canal deployer package & canal adapter package parameters (1)

1. Usage scenarios

  • canal deployer is a canal standard package, which can be regarded as a canal server . It is responsible for masquerading as a mysql slave library, receiving, parsing binlog and delivering it to the specified target ( RDS , MQ or canal adapter )
  • The canal adapter is a canal client, which can be regarded as a canal client . Among them, RDB includes Oracle , MySQL , PostgreSQL , SQLServer and other databases

2. Detailed explanation of canal deployer package parameters

2.1. canal deployer package directory structure

tree canal  expand source code

  • bin - store start, restart, stop scripts
  • conf - configuration file directory
  • lib - store library files, no need to operate this directory
  • logs - storage log directory

2.2. conf directory

tree canal conf  expand source code

  • canal.properties - canal program main configuration file

argument

illustrate

Defaults

example (--to keep the default)

canal.ip

The local IP information bound to the canal server . If not configured, a local IP is selected by default to start the service

none

canal.register.ip

The ip registered by the canal server to the zk cluster

none

canal.port

The port where the canal server provides socket services

11111

--

canal.metrics.pull.port

Monitoring interface port (used with Prometheus)

11112

--

canal.admin.port

Access port for canal admin

11110

--

canal.admin.user

Canal admin login user

admin

--

canal.admin.passwd

Canal admin login user password

--

canal.zkServers

zookeeper server cluster address

--

canal.zookeeper.flush.period

The update frequency of canal persistent data to zookeeper, in milliseconds

1000

--

canal.withoutNetty

Whether to close the netty service on the server side

false

--

canal.serverMode

tcp: The client pulls incremental data from the Canal server through tcp

Kafka: The Canal server synchronizes incremental data to Kafka, and the client consumes data from Kafka. At this time, the client cannot perceive the existence of Canal, and only needs to interact with Kafka

RocketMQ: Same as kafka, incremental data is synchronized to RocketMQ

tcp

--

canal.file.data.dir

flush meta cursor/parse position to file . Record the consumption site to the file, when using the spring/file-instance.xml configuration file

${canal.conf.dir}

--

canal.file.flush.period

The update frequency of canal persistent data to the file, in milliseconds

1000

--

canal.instance.memory.buffer.size

The number of cacheable buffer records in the canal memory store, which needs to be an index of 2

16384

--

canal.instance.memory.buffer.memunit

The unit size of the memory record, the default is 1KB, and the combination of buffer.size determines the final memory usage size

1024

--

canal.instance.memory.batch.mode

Data cache mode in canal memory store
1. ITEMSIZE: limit according to buffer.size, only limit the number of records
2. MEMSIZE: limit the size of cache records according to the size of buffer.size * buffer.memunit

MEMSIZE

--

canal.instance.memory.rawEntry

batch.mode related parameters, the default is fine

true

--

canal.instance.detecting.enable

Whether to enable heartbeat check

false

--

canal.instance.detecting.sql

heartbeat check sql

select 1

--

canal.instance.detecting.interval.time

Heartbeat check frequency, in seconds

3

--

canal.instance.detecting.retry.threshold

心跳检查失败重试次数

3

--

canal.instance.detecting.heartbeatHaEnable

心跳检查失败后,是否开启自动mysql自动切换
说明:比如心跳检查失败超过阀值后,如果该配置为true,canal就会自动链到mysql备库获取binlog数据

false

--

canal.instance.transaction.size

最大事务完整解析的长度支持。超过该长度后,一个事务可能会被拆分成多次提交到canal store中,无法保证事务的完整可见性

1024

--

canal.instance.fallbackIntervalInSeconds

canal发生mysql切换时,在新的mysql库上查找binlog时需要往前查找的时间,单位秒
说明:mysql主备库可能存在解析延迟或者时钟不统一,需要回退一段时间,保证数据不丢

60

--

canal.instance.network.receiveBufferSize

网络链接参数,SocketOptions.SO_RCVBUF

16384

--

canal.instance.network.sendBufferSize

网络链接参数,SocketOptions.SO_SNDBUF

16384

--

canal.instance.network.soTimeout

网络链接参数,SocketOptions.SO_TIMEOUT

30

--

canal.instance.filter.druid.ddl

是否使用druid处理所有的ddl解析来获取库和表名

true

--

canal.instance.filter.query.dcl

是否忽略dcl语句

false

--

canal.instance.filter.query.dml

是否忽略dml语句

false

--

canal.instance.filter.query.ddl

是否忽略ddl语句

false

--

canal.instance.filter.table.error

是否忽略binlog表结构获取失败的异常
(主要解决回溯binlog时,对应表已被删除或者表结构和binlog不一致的情况)

false

--

canal.instance.filter.rows

是否忽略dml的数据变更事件
(主要针对用户只订阅ddl/dcl的操作)

false

--

canal.instance.filter.transaction.entry

是否忽略事务头和尾,比如针对写入kakfa的消息时,不需要写入TransactionBegin/Transactionend事件

false

--

canal.instance.binlog.format

支持的binlog/format格式列表
(otter会有支持format格式限制)

ROW,STATEMENT,MIXED

--

canal.instance.binlog.image

支持的binlog/image格式列表
(otter会有支持format格式限制)

FULL,MINIMAL,NOBLOB

--

canal.instance.get.ddl.isolation

ddl语句是否单独一个batch返回
(比如下游dml/ddl如果做batch内无序并发处理,会导致结构不一致)

false

--

canal.instance.parser.parallel

是否开启binlog并行解析模式
(串行解析资源占用少,但性能有瓶颈, 并行解析可以提升近2.5倍+)

true

--

canal.instance.parser.parallelBufferSize

binlog并行解析的异步ringbuffer队列
(必须为2的指数)

256

--

canal.instance.tsdb.enable

是否开启tablemeta的 tsdb 功能

true

false

canal.instance.tsdb.dir

主要针对h2-tsdb.xml时对应h2文件的存放目录,默认为conf/xx/h2.mv.db

[Math Processing Error]�����.����.����.���:../����/{canal.instance.destination:}

--

canal.instance.tsdb.url

jdbc url的配置
(h2的地址为默认值,如果是mysql需要自行定义)

jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;

--

canal.instance.tsdb.dbUsername

tsdb用户名

canal

--

canal.instance.tsdb.dbPassword

tsdb密码

canal

--

canal.instance.tsdb.snapshot.interval

导出快照间隔,默认24小时

24

--

canal.instance.tsdb.snapshot.expire

清理快照时间间隔,默认360小时

360

--

canal.aliyun.accessKey

阿里云 access key(如果不需要在本地binlog超过18小时被清理后自动下载oss上的binlog,可以忽略该值)

--

canal.aliyun.secretKey

阿里云 secret key(如果不需要在本地binlog超过18小时被清理后自动下载oss上的binlog,可以忽略该值)

--

  • logback.xml —— 日志功能配置文件,一般不用修改
  • metrics —— 监控项配置文件目录
  • spring —— spring 框架配置文件目录,其中 *-instance.xml 文件用于指定 binlog 的位点信息存放于文件、内存、zk 等位置
    • default-instance.xml store选择了内存模式,其余的parser/sink依赖的位点管理选择了持久化模式,目前持久化的方式主要是写入zookeeper,保证数据集群共享。
      • 特点:支持HA
      • 场景:生产环境,集群化部署.
    • memory-instance.xml:所有的组件(parser , sink , store)都选择了内存版模式,记录位点的都选择了memory模式,重启后又会回到初始位点进行解析。
      • 特点:速度最快,依赖最少(不需要zookeeper)
      • 场景:一般应用在quickstart,或者是出现问题后,进行数据分析的场景,不应该将其应用于生产环境
    • group-instance.xml:主要针对需要进行多库合并时,可以将多个物理instance合并为一个逻辑instance,提供客户端访问。
    • file-instance.xmlstore选择了内存模式,其余的parser/sink依赖的位点管理选择了持久化模式,目前持久化的方式主要是写入文件,文件位置在instance目录下meta.dat,当前Canal节点重启会从该文件读取解析位置,无法在数据集群共享。
  • mid_db —— canal 实例配置文件,主要配置 mysql binlog 的起始位置、表过滤、MQ 目标 topic 等信息

2.3. canal.properties 文件详解

  • canal.properties 文件分为了4大部分
    • common argument
    • destinations
    • MQ
    • Kafka Kerberos Info

2.3.1. common argument 部分

2.3.2. destinations 部分

argument

说明

默认值

示例

canal.destinations

当前server上部署的instance列表,多个实例用逗号分隔

mysql_mysql

canal.conf.dir

conf 目录所在的路径

../conf

--

canal.auto.scan

开启instance自动扫描
如果配置为true,canal.conf.dir目录下的instance配置变化会自动触发:
a. instance目录新增:触发instance配置载入,lazy为true时则自动启动
b. instance目录删除:卸载对应instance配置,如已启动则进行关闭
c. instance.properties文件变化:reload instance配置,如已启动自动进行重启操作

true

--

canal.auto.scan.interval

instance自动扫描的间隔时间,单位秒

5

--

canal.instance.tsdb.spring.xml

tsdb 的 xml 配置文件

classpath:spring/tsdb/h2-tsdb.xml

--

canal.instance.global.mode

全局配置加载方式

spring

--

canal.instance.global.lazy

全局lazy模式

false

--

canal.instance.global.manager.address

全局的manager配置方式的连接信息

${canal.admin.manager}

--

canal.instance.global.spring.xml

全局的spring配置方式的组件文件,连接 zk 使用 default 文件

classpath:spring/file-instance.xml

classpath:spring/default-instance.xml

2.3.3. MQ 部分

argument

说明

默认值

示例

canal.mq.servers

kafka为bootstrap.servers
rocketMQ中为nameserver列表

127.0.0.1:6667

--

canal.mq.retries

发送失败重试次数

0

--

canal.mq.batchSize

kafkaProducerConfig.BATCH_SIZE_CONFIG
rocketMQ无意义

16384

--

canal.mq.maxRequestSize

kafkaProducerConfig.MAX_REQUEST_SIZE_CONFIG
rocketMQ无意义

1048576

--

canal.mq.lingerMs

kafkaProducerConfig.LINGER_MS_CONFIG , 如果是flatMessage格式建议将该值调大, 如: 200
rocketMQ无意义

100

--

canal.mq.bufferMemory

kafkaProducerConfig.BUFFER_MEMORY_CONFIG
rocketMQ无意义

33554432

--

canal.mq.canalBatchSize

Canal的batch size, 默认50K, 由于kafka最大消息体限制请勿超过1M(900K以下)

50

--

canal.mq.canalGetTimeout

Canal get数据的超时时间, 单位: 毫秒, 空为不限超时

100

--

canal.mq.flatMessage

是否为flat json格式对象

true

--

canal.mq.compressionType

压缩类型

none

--

canal.mq.acks

kafkaProducerConfig.ACKS_CONFIG
rocketMQ无意义

all

--

canal.mq.producerGroup

kafka无意义
rocketMQ为ProducerGroup名

Canal-Producer

--

canal.mq.accessChannel

kafka无意义
rocketMQ为channel模式,如果为aliyun则配置为cloud

local

--

2.3.4. Kafka Kerberos Info 部分

argument

说明

默认值

示例(--为保持默认)

canal.mq.kafka.kerberos.enable

kafkaProducerConfig.ACKS_CONFIG
rocketMQ无意义

false

--

canal.mq.kafka.kerberos.krb5FilePath

kafka kerberos认证
rocketMQ无意义

"../conf/kerberos/krb5.conf"

--

canal.mq.kafka.kerberos.jaasFilePath

kafka kerberos认证
rocketMQ无意义

"../conf/kerberos/jaas.conf"

--

Guess you like

Origin blog.csdn.net/2301_76957510/article/details/129872083