当前位置:   article > 正文

docker 安装canal

docker 安装canal

一、新建文件夹

新建文件夹logs, 新建文件canal.properties instance.properties docker.compose.yml

 canal.propertie 修改如下:

修改instance.properties内容如下

 1.1 canal.properties

  1. #################################################
  2. ######### common argument #############
  3. #################################################
  4. # tcp bind ip
  5. canal.ip =
  6. # register ip to zookeeper
  7. canal.register.ip =
  8. canal.port = 11111
  9. canal.metrics.pull.port = 11112
  10. # canal instance user/passwd
  11. # canal.user = canal
  12. # canal.passwd = E3619321C1A937C46A0D8BD1DAC39F93B27D4458
  13. # canal admin config
  14. #canal.admin.manager = 127.0.0.1:8089
  15. canal.admin.port = 11110
  16. canal.admin.user = admin
  17. canal.admin.passwd = 4ACFE3202A5FF5CF467898FC58AAB1D615029441
  18. # admin auto register
  19. #canal.admin.register.auto = true
  20. #canal.admin.register.cluster =
  21. #canal.admin.register.name =
  22. canal.zkServers =
  23. # flush data to zk
  24. canal.zookeeper.flush.period = 1000
  25. canal.withoutNetty = false
  26. # tcp, kafka, rocketMQ, rabbitMQ, pulsarMQ
  27. canal.serverMode = rabbitMQ
  28. # flush meta cursor/parse position to file
  29. canal.file.data.dir = ${canal.conf.dir}
  30. canal.file.flush.period = 1000
  31. ## memory store RingBuffer size, should be Math.pow(2,n)
  32. canal.instance.memory.buffer.size = 16384
  33. ## memory store RingBuffer used memory unit size , default 1kb
  34. canal.instance.memory.buffer.memunit = 1024
  35. ## meory store gets mode used MEMSIZE or ITEMSIZE
  36. canal.instance.memory.batch.mode = MEMSIZE
  37. canal.instance.memory.rawEntry = true
  38. ## detecing config
  39. canal.instance.detecting.enable = false
  40. #canal.instance.detecting.sql = insert into retl.xdual values(1,now()) on duplicate key update x=now()
  41. canal.instance.detecting.sql = select 1
  42. canal.instance.detecting.interval.time = 3
  43. canal.instance.detecting.retry.threshold = 3
  44. canal.instance.detecting.heartbeatHaEnable = false
  45. # support maximum transaction size, more than the size of the transaction will be cut into multiple transactions delivery
  46. canal.instance.transaction.size = 1024
  47. # mysql fallback connected to new master should fallback times
  48. canal.instance.fallbackIntervalInSeconds = 60
  49. # network config
  50. canal.instance.network.receiveBufferSize = 16384
  51. canal.instance.network.sendBufferSize = 16384
  52. canal.instance.network.soTimeout = 30
  53. # binlog filter config
  54. canal.instance.filter.druid.ddl = true
  55. canal.instance.filter.query.dcl = false
  56. canal.instance.filter.query.dml = false
  57. canal.instance.filter.query.ddl = false
  58. canal.instance.filter.table.error = false
  59. canal.instance.filter.rows = false
  60. canal.instance.filter.transaction.entry = false
  61. canal.instance.filter.dml.insert = false
  62. canal.instance.filter.dml.update = false
  63. canal.instance.filter.dml.delete = false
  64. # binlog format/image check
  65. canal.instance.binlog.format = ROW,STATEMENT,MIXED
  66. canal.instance.binlog.image = FULL,MINIMAL,NOBLOB
  67. # binlog ddl isolation
  68. canal.instance.get.ddl.isolation = false
  69. # parallel parser config
  70. canal.instance.parser.parallel = true
  71. ## concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors()
  72. #canal.instance.parser.parallelThreadSize = 16
  73. ## disruptor ringbuffer size, must be power of 2
  74. canal.instance.parser.parallelBufferSize = 256
  75. # table meta tsdb info
  76. canal.instance.tsdb.enable = true
  77. canal.instance.tsdb.dir = ${canal.file.data.dir:../conf}/${canal.instance.destination:}
  78. canal.instance.tsdb.url = jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
  79. canal.instance.tsdb.dbUsername = canal
  80. canal.instance.tsdb.dbPassword = canal
  81. # dump snapshot interval, default 24 hour
  82. canal.instance.tsdb.snapshot.interval = 24
  83. # purge snapshot expire , default 360 hour(15 days)
  84. canal.instance.tsdb.snapshot.expire = 360
  85. #################################################
  86. ######### destinations #############
  87. #################################################
  88. canal.destinations = example
  89. # conf root dir
  90. canal.conf.dir = ../conf
  91. # auto scan instance dir add/remove and start/stop instance
  92. canal.auto.scan = true
  93. canal.auto.scan.interval = 5
  94. # set this value to 'true' means that when binlog pos not found, skip to latest.
  95. # WARN: pls keep 'false' in production env, or if you know what you want.
  96. canal.auto.reset.latest.pos.mode = false
  97. canal.instance.tsdb.spring.xml = classpath:spring/tsdb/h2-tsdb.xml
  98. #canal.instance.tsdb.spring.xml = classpath:spring/tsdb/mysql-tsdb.xml
  99. canal.instance.global.mode = spring
  100. canal.instance.global.lazy = false
  101. canal.instance.global.manager.address = ${canal.admin.manager}
  102. #canal.instance.global.spring.xml = classpath:spring/memory-instance.xml
  103. canal.instance.global.spring.xml = classpath:spring/file-instance.xml
  104. #canal.instance.global.spring.xml = classpath:spring/default-instance.xml
  105. ##################################################
  106. ######### MQ Properties #############
  107. ##################################################
  108. # aliyun ak/sk , support rds/mq
  109. canal.aliyun.accessKey =
  110. canal.aliyun.secretKey =
  111. canal.aliyun.uid=
  112. canal.mq.flatMessage = true
  113. canal.mq.canalBatchSize = 50
  114. canal.mq.canalGetTimeout = 100
  115. # Set this value to "cloud", if you want open message trace feature in aliyun.
  116. canal.mq.accessChannel = local
  117. canal.mq.database.hash = true
  118. canal.mq.send.thread.size = 30
  119. canal.mq.build.thread.size = 8
  120. ##################################################
  121. ######### Kafka #############
  122. ##################################################
  123. kafka.bootstrap.servers = 127.0.0.1:9092
  124. kafka.acks = all
  125. kafka.compression.type = none
  126. kafka.batch.size = 16384
  127. kafka.linger.ms = 1
  128. kafka.max.request.size = 1048576
  129. kafka.buffer.memory = 33554432
  130. kafka.max.in.flight.requests.per.connection = 1
  131. kafka.retries = 0
  132. kafka.kerberos.enable = false
  133. kafka.kerberos.krb5.file = ../conf/kerberos/krb5.conf
  134. kafka.kerberos.jaas.file = ../conf/kerberos/jaas.conf
  135. # sasl demo
  136. # kafka.sasl.jaas.config = org.apache.kafka.common.security.scram.ScramLoginModule required \\n username=\"alice\" \\npassword="alice-secret\";
  137. # kafka.sasl.mechanism = SCRAM-SHA-512
  138. # kafka.security.protocol = SASL_PLAINTEXT
  139. ##################################################
  140. ######### RocketMQ #############
  141. ##################################################
  142. rocketmq.producer.group = test
  143. rocketmq.enable.message.trace = false
  144. rocketmq.customized.trace.topic =
  145. rocketmq.namespace =
  146. rocketmq.namesrv.addr = 127.0.0.1:9876
  147. rocketmq.retry.times.when.send.failed = 0
  148. rocketmq.vip.channel.enabled = false
  149. rocketmq.tag =
  150. ##################################################
  151. ######### RabbitMQ #############
  152. ##################################################
  153. rabbitmq.host = 192.168.11.44:5672
  154. rabbitmq.virtual.host = /
  155. rabbitmq.exchange = e1
  156. rabbitmq.username = guest
  157. rabbitmq.password = guest
  158. rabbitmq.deliveryMode = 2
  159. ##################################################
  160. ######### Pulsar #############
  161. ##################################################
  162. pulsarmq.serverUrl =
  163. pulsarmq.roleToken =
  164. pulsarmq.topicTenantPrefix =

1.2  instance.properties

  1. #################################################
  2. ## mysql serverId , v1.0.26+ will autoGen
  3. # canal.instance.mysql.slaveId=0
  4. # enable gtid use true/false
  5. canal.instance.gtidon=false
  6. # position info
  7. canal.instance.master.address=192.168.11.79:3308
  8. canal.instance.master.journal.name=
  9. canal.instance.master.position=
  10. canal.instance.master.timestamp=
  11. canal.instance.master.gtid=
  12. # rds oss binlog
  13. canal.instance.rds.accesskey=
  14. canal.instance.rds.secretkey=
  15. canal.instance.rds.instanceId=
  16. # table meta tsdb info
  17. canal.instance.tsdb.enable=true
  18. #canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
  19. #canal.instance.tsdb.dbUsername=canal
  20. #canal.instance.tsdb.dbPassword=canal
  21. #canal.instance.standby.address =
  22. #canal.instance.standby.journal.name =
  23. #canal.instance.standby.position =
  24. #canal.instance.standby.timestamp =
  25. #canal.instance.standby.gtid=
  26. # username/password
  27. canal.instance.dbUsername=root
  28. canal.instance.dbPassword=123456
  29. canal.instance.connectionCharset = UTF-8
  30. # enable druid Decrypt database password
  31. canal.instance.enableDruid=false
  32. #canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==
  33. # table regex
  34. canal.instance.filter.regex=.*\\..*
  35. # table black regex
  36. canal.instance.filter.black.regex=mysql\\.slave_.*
  37. # table field filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
  38. #canal.instance.filter.field=test1.t_product:id/subject/keywords,test2.t_company:id/name/contact/ch
  39. # table field black filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
  40. #canal.instance.filter.black.field=test1.t_product:subject/product_image,test2.t_company:id/name/contact/ch
  41. # mq config
  42. canal.mq.topic=example
  43. # dynamic topic route by schema or table regex
  44. #canal.mq.dynamicTopic=mytest1.user,topic2:mytest2\\..*,.*\\..*
  45. canal.mq.partition=0
  46. # hash partition config
  47. #canal.mq.enableDynamicQueuePartition=false
  48. #canal.mq.partitionsNum=3
  49. #canal.mq.dynamicTopicPartitionNum=test.*:4,mycanal:6
  50. #canal.mq.partitionHash=test.table:id^name,.*\\..*
  51. #################################################

1.3 docker.compose.yml

  1. version: '3'
  2. services:
  3. canal:
  4. container_name: canal_latest
  5. image: canal/canal-server:v1.1.5
  6. restart: always
  7. ports:
  8. - 11111:11111
  9. volumes:
  10. - ./canal.properties:/home/admin/canal-server/conf/canal.properties
  11. - ./instance.properties:/home/admin/canal-server/conf/example/instance.properties
  12. - ./logs:/home/admin/canal-server/logs

二、启动容器 :先进入canal 目录

docker-compose up -d

三、 手动创建一个交换机 ,名字和配置文件保持一致

然后绑定一个消息队列,修改自己配置的mysql 数据

 

观察消息队列

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号