canal.properties配置
canal.id = 1
canal.ip =
canal.port= 11111
canal.metrics.pull.port = 11112
#指定zk集群的位置
canal.zkServers = xxxxxx:2181
canal.zookeeper.flush.period = 1000
canal.withoutNetty = false
# 使用rocketMQ
canal.serverMode = rocketmq
# flush meta cursor/parse position to file
canal.file.data.dir = ${canal.conf.dir}
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
##内存模式
canal.instance.memory.batch.mode = MEMSIZE
canal.instance.memory.rawEntry = true
## canal检测instance的一些配置
canal.instance.detecting.enable = false
canal.instance.detecting.sql = select 1
canal.instance.detecting.interval.time = 3
canal.instance.detecting.retry.threshold = 3
canal.instance.detecting.heartbeatHaEnable = false
# 支持最大事务 这些无所谓
canal.instance.transaction.size = 1024
canal.instance.fallbackIntervalInSeconds = 60
# 网络连接的一些配置
canal.instance.network.receiveBufferSize = 16384
canal.instance.network.sendBufferSize = 16384
canal.instance.network.soTimeout = 30
# binlog filter config
canal.instance.filter.druid.ddl = true
canal.instance.filter.query.dcl = true
canal.instance.filter.query.dml = false
canal.instance.filter.query.ddl = true
canal.instance.filter.table.error = true
canal.instance.filter.rows = false
canal.instance.filter.transaction.entry = true
# 只支持binlog的 ROW模式
canal.instance.binlog.format = ROW
canal.instance.binlog.image = FULL,MINIMAL,NOBLOB
# binlog ddl isolation
canal.instance.get.ddl.isolation = false
# parallel parser config
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
# table meta tsdb info
canal.instance.tsdb.enable=false
canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:}
canal.instance.tsdb.url=jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
canal.instance.tsdb.dbUsername=canal
canal.instance.tsdb.dbPassword=canal
# dump snapshot interval, default 24 hour
canal.instance.tsdb.snapshot.interval=24
# purge snapshot expire , default 360 hour(15 days)
canal.instance.tsdb.snapshot.expire=360
# rds oss binlog account
canal.instance.rds.accesskey =
canal.instance.rds.secretkey =
#指定具体的instance
canal.destinations = account,balance,distribution,inventory,member,product,order
# conf root dir
canal.conf.dir = ../conf
# 自动检测也开启
canal.auto.scan = true
canal.auto.scan.interval = 5
canal.instance.tsdb.spring.xml=classpath:spring/tsdb/h2-tsdb.xml
#canal.instance.tsdb.spring.xml=classpath:spring/tsdb/mysql-tsdb.xml
#配置文件模式是spring
canal.instance.global.mode = spring
canal.instance.global.lazy = false
#使用default-instance.xml这个xml
canal.instance.global.spring.xml = classpath:spring/default-instance.xml
总结: 整体看下来canal.properties的配置的关键点也能读懂,主要是以下几点
- binlog只支持ROW模式
- instance配置了account,balance,….,order等
- 指定了zk
其他的配置可能由于我还不太熟练,所以影响不深
account/instance.properties解析
#指定slaveId
canal.instance.mysql.slaveId=1101
# 直接关掉 gtidon
canal.instance.gtidon=false
# 监听的数据库
canal.instance.master.address=10.11.7.24:3306
canal.instance.master.journal.name=
canal.instance.master.position=
canal.instance.master.timestamp=
canal.instance.master.gtid=
# rds oss binlog
canal.instance.rds.accesskey=
canal.instance.rds.secretkey=
canal.instance.rds.instanceId=
# table meta tsdb info
canal.instance.tsdb.enable=false
#canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
#canal.instance.tsdb.dbUsername=canal
#canal.instance.tsdb.dbPassword=T9UKK3ZL
#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =
#canal.instance.standby.gtid=
#配置用户名密码
canal.instance.dbUsername=canal
canal.instance.dbPassword=canal-rfaDv5X3Vk92
canal.instance.connectionCharset = utf8
canal.instance.defaultDatabaseName = account_db
# enable druid Decrypt database password
canal.instance.enableDruid=false
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==
# 同步的表数据
canal.instance.filter.regex = account_db.sys_tenant,account_db.sys_user,account_db.sys_user_tenant
# table black regex
canal.instance.filter.black.regex=
总结:instance.properties的配置相对而言好读,配置少,除了个别,比如gtid到底是个啥?tsdb?等其他都简单易懂
- 指定了监听的表信息:sys_tenant,sys_user,sys_user_tenant
- 指定数据库的连接地址用户名和密码
MQ的配置呢?
canal中已经配置rocketMQ模式,在canal-1.1.5已经可以在instance.properties中配置啦,但是这里锥智使用的是canal-1.1.1版本,所以需要在mq.yml中配置,这个yml也是canal自带的。
servers: xxxxxx:9876
retries: 0
batchSize: 16384
lingerMs: 1
bufferMemory: 33554432
# Canal的batch size, 默认50K, 由于kafka最大消息体限制请勿超过1M(900K以下)
canalBatchSize: 50
# Canal get数据的超时时间, 单位: 毫秒, 0为不限超时
canalGetTimeout: 100
flatMessage: true
canalDestinations:
- canalDestination: product
topic: product-sync-canal
partition: 0
- canalDestination: order
topic: order-sync-canal
partition: 0
- canalDestination: member
topic: member-sync-canal
partition: 0
- canalDestination: balance
topic: balance-sync-canal
partition: 0
- canalDestination: inventory
topic: inventory-sync-canal
partition: 0
- canalDestination: distribution
topic: distribution-sync-canal
partition: 0
- canalDestination: account
topic: account-sync-canal
partition: 0
# #对应topic分区数量
# partitionsNum: 3
# partitionHash:
# #库名.表名: 唯一主键
# mytest.person: id
其他
其他的instance配置都类似就不一个一个看啦