canal.properties配置

  1. canal.id = 1
  2. canal.ip =
  3. canal.port= 11111
  4. canal.metrics.pull.port = 11112
  5. #指定zk集群的位置
  6. canal.zkServers = xxxxxx:2181
  7. canal.zookeeper.flush.period = 1000
  8. canal.withoutNetty = false
  9. # 使用rocketMQ
  10. canal.serverMode = rocketmq
  11. # flush meta cursor/parse position to file
  12. canal.file.data.dir = ${canal.conf.dir}
  13. canal.file.flush.period = 1000
  14. ## memory store RingBuffer size, should be Math.pow(2,n)
  15. canal.instance.memory.buffer.size = 16384
  16. ## memory store RingBuffer used memory unit size , default 1kb
  17. canal.instance.memory.buffer.memunit = 1024
  18. ##内存模式
  19. canal.instance.memory.batch.mode = MEMSIZE
  20. canal.instance.memory.rawEntry = true
  21. ## canal检测instance的一些配置
  22. canal.instance.detecting.enable = false
  23. canal.instance.detecting.sql = select 1
  24. canal.instance.detecting.interval.time = 3
  25. canal.instance.detecting.retry.threshold = 3
  26. canal.instance.detecting.heartbeatHaEnable = false
  27. # 支持最大事务 这些无所谓
  28. canal.instance.transaction.size = 1024
  29. canal.instance.fallbackIntervalInSeconds = 60
  30. # 网络连接的一些配置
  31. canal.instance.network.receiveBufferSize = 16384
  32. canal.instance.network.sendBufferSize = 16384
  33. canal.instance.network.soTimeout = 30
  34. # binlog filter config
  35. canal.instance.filter.druid.ddl = true
  36. canal.instance.filter.query.dcl = true
  37. canal.instance.filter.query.dml = false
  38. canal.instance.filter.query.ddl = true
  39. canal.instance.filter.table.error = true
  40. canal.instance.filter.rows = false
  41. canal.instance.filter.transaction.entry = true
  42. # 只支持binlog的 ROW模式
  43. canal.instance.binlog.format = ROW
  44. canal.instance.binlog.image = FULL,MINIMAL,NOBLOB
  45. # binlog ddl isolation
  46. canal.instance.get.ddl.isolation = false
  47. # parallel parser config
  48. canal.instance.parser.parallel = true
  49. ## concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors()
  50. #canal.instance.parser.parallelThreadSize = 16
  51. ## disruptor ringbuffer size, must be power of 2
  52. canal.instance.parser.parallelBufferSize = 256
  53. # table meta tsdb info
  54. canal.instance.tsdb.enable=false
  55. canal.instance.tsdb.dir=${canal.file.data.dir:../conf}/${canal.instance.destination:}
  56. canal.instance.tsdb.url=jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
  57. canal.instance.tsdb.dbUsername=canal
  58. canal.instance.tsdb.dbPassword=canal
  59. # dump snapshot interval, default 24 hour
  60. canal.instance.tsdb.snapshot.interval=24
  61. # purge snapshot expire , default 360 hour(15 days)
  62. canal.instance.tsdb.snapshot.expire=360
  63. # rds oss binlog account
  64. canal.instance.rds.accesskey =
  65. canal.instance.rds.secretkey =
  66. #指定具体的instance
  67. canal.destinations = account,balance,distribution,inventory,member,product,order
  68. # conf root dir
  69. canal.conf.dir = ../conf
  70. # 自动检测也开启
  71. canal.auto.scan = true
  72. canal.auto.scan.interval = 5
  73. canal.instance.tsdb.spring.xml=classpath:spring/tsdb/h2-tsdb.xml
  74. #canal.instance.tsdb.spring.xml=classpath:spring/tsdb/mysql-tsdb.xml
  75. #配置文件模式是spring
  76. canal.instance.global.mode = spring
  77. canal.instance.global.lazy = false
  78. #使用default-instance.xml这个xml
  79. canal.instance.global.spring.xml = classpath:spring/default-instance.xml

总结: 整体看下来canal.properties的配置的关键点也能读懂,主要是以下几点

  • binlog只支持ROW模式
  • instance配置了account,balance,….,order等
  • 指定了zk

其他的配置可能由于我还不太熟练,所以影响不深

account/instance.properties解析

  1. #指定slaveId
  2. canal.instance.mysql.slaveId=1101
  3. # 直接关掉 gtidon
  4. canal.instance.gtidon=false
  5. # 监听的数据库
  6. canal.instance.master.address=10.11.7.24:3306
  7. canal.instance.master.journal.name=
  8. canal.instance.master.position=
  9. canal.instance.master.timestamp=
  10. canal.instance.master.gtid=
  11. # rds oss binlog
  12. canal.instance.rds.accesskey=
  13. canal.instance.rds.secretkey=
  14. canal.instance.rds.instanceId=
  15. # table meta tsdb info
  16. canal.instance.tsdb.enable=false
  17. #canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
  18. #canal.instance.tsdb.dbUsername=canal
  19. #canal.instance.tsdb.dbPassword=T9UKK3ZL
  20. #canal.instance.standby.address =
  21. #canal.instance.standby.journal.name =
  22. #canal.instance.standby.position =
  23. #canal.instance.standby.timestamp =
  24. #canal.instance.standby.gtid=
  25. #配置用户名密码
  26. canal.instance.dbUsername=canal
  27. canal.instance.dbPassword=canal-rfaDv5X3Vk92
  28. canal.instance.connectionCharset = utf8
  29. canal.instance.defaultDatabaseName = account_db
  30. # enable druid Decrypt database password
  31. canal.instance.enableDruid=false
  32. #canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==
  33. # 同步的表数据
  34. canal.instance.filter.regex = account_db.sys_tenant,account_db.sys_user,account_db.sys_user_tenant
  35. # table black regex
  36. 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自带的。

  1. servers: xxxxxx:9876
  2. retries: 0
  3. batchSize: 16384
  4. lingerMs: 1
  5. bufferMemory: 33554432
  6. # Canal的batch size, 默认50K, 由于kafka最大消息体限制请勿超过1M(900K以下)
  7. canalBatchSize: 50
  8. # Canal get数据的超时时间, 单位: 毫秒, 0为不限超时
  9. canalGetTimeout: 100
  10. flatMessage: true
  11. canalDestinations:
  12. - canalDestination: product
  13. topic: product-sync-canal
  14. partition: 0
  15. - canalDestination: order
  16. topic: order-sync-canal
  17. partition: 0
  18. - canalDestination: member
  19. topic: member-sync-canal
  20. partition: 0
  21. - canalDestination: balance
  22. topic: balance-sync-canal
  23. partition: 0
  24. - canalDestination: inventory
  25. topic: inventory-sync-canal
  26. partition: 0
  27. - canalDestination: distribution
  28. topic: distribution-sync-canal
  29. partition: 0
  30. - canalDestination: account
  31. topic: account-sync-canal
  32. partition: 0
  33. # #对应topic分区数量
  34. # partitionsNum: 3
  35. # partitionHash:
  36. # #库名.表名: 唯一主键
  37. # mytest.person: id

其他

其他的instance配置都类似就不一个一个看啦