Canal-server 的配置

#################################################
## mysql serverId , v1.0.26+ will autoGen
#canal.instance.mysql.slaveId=101

# enable gtid use true/false
canal.instance.gtidon=false

# position info
canal.instance.master.address=172.19.0.31:32060
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=true
#canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
#canal.instance.tsdb.dbUsername=canal
#canal.instance.tsdb.dbPassword=canal

#canal.instance.standby.address =
#canal.instance.standby.journal.name =
#canal.instance.standby.position =
#canal.instance.standby.timestamp =
#canal.instance.standby.gtid=

# username/password
canal.instance.dbUsername=canal
canal.instance.dbPassword=canal
canal.instance.connectionCharset = UTF-8
#canal.instance.defaultDatabaseName = dc_canal
# enable druid Decrypt database password
canal.instance.enableDruid=false

#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==

# table regex
canal.instance.filter.regex=dc_canal_dic_dt_data
# table black regex
canal.instance.filter.black.regex=
# table field filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
#canal.instance.filter.field=test1.t_product:id/subject/keywords,test2.t_company:id/name/contact/ch
# table field black filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
#canal.instance.filter.black.field=test1.t_product:subject/product_image,test2.t_company:id/name/contact/ch

# mq config
canal.mq.topic=dc_canal_dic_dt_data
# dynamic topic route by schema or table regex
#canal.mq.dynamicTopic=mytest1.user,mytest2\\..*,.*\\..*
canal.mq.partition=0
# hash partition config
#canal.mq.partitionsNum=3
#canal.mq.partitionHash=test.table:id^name,.*\\..*
#################################################

canal-adapter 配置

application.yml
server:
  port: 8081
spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
    default-property-inclusion: non_null
canal.conf:
  mode: tcp #tcp kafka rocketMQ rabbitMQ
  flatMessage: true
  zookeeperHosts:
  syncBatchSize: 1000
  retries: -1
  timeout:
  accessKey:
  secretKey:
  consumerProperties:
    # canal tcp consumer
    canal.tcp.server.host: 172.19.0.31:30740
    #canal.tcp.zookeeper.hosts:
    canal.tcp.batch.size: 500
    #canal.tcp.username:
    #canal.tcp.password:
  srcDataSources:  
  ## 源库
    defaultDS:
      url: jdbc:mysql://172.19.0.31:32060/dc-canal?useUnicode=true
      username: canal
      password: canal
  canalAdapters:
  - instance: dc_canal_dic_dt_data  # canal instance Name or mq topic name
    groups:
    - groupId: g1
      outerAdapters:
      - name: logger
      - name: rdb
        key: mysql1
        properties:
          jdbc.driverClassName: com.mysql.jdbc.Driver
          jdbc.url: jdbc:mysql://172.19.0.31:32060/sync_canal?useUnicode=true
          # 目标数据库,将新数据同步到这里
          jdbc.username: canal
          jdbc.password: canal
          druid.stat.enable: false
          druid.stat.slowSqlMillis: 1000

mytest_user.yml

dataSourceKey: defaultDS  
destination: dc_canal_dic_dt_data
groupId: g1
outerAdapterKey: mysql1
concurrent: true
dbMapping:
  database: dc-canal          # 源库的名字
  table: dic_dt_data          # 源库的表名
  targetTable: sync_canal.dic_dt_data   ### 目标库名表名
  targetPk:
    id: id
  mapAll: true
#  targetColumns:
#   id:
#    name:
#    role_id:
#    c_time:
#    test1:
  etlCondition: "where c_time>={}"
  commitBatch: 3000 # 批量提交的大小

在dc_canal 库的dc_dic_data 表中插入数据

但是没有同步到sync_canal 库的dc_dic_data表中

kind: Service apiVersion: v1 metadata: name: canal-server namespace: iot spec: ports: - name: http port: 11110 targetPort: 11110 - name: tcp11111 port: 11111 protocol: TCP targetPort: 11111 - name: tcp11112 protocol: TCP port: 11112 targetPort: 11112

type: NodePort selector: app.kubernetes.io/name: canal-server app: canal-server

comments powered by Disqus