使用canal将数据从oceanbase同步到mysql不生效

【 使用环境 】测试环境
【 OB or 其他组件 】
【 使用版本 】4.2.1.3
【问题描述】
按照文档:OceanBase分布式数据库-海量数据 笔笔算数 进行canal的安装与配置,打算将oceanbase的一个表同步到mysql,服务都正常启动,日志也没见报错,但是同步不生效

【附件及日志】
如下为的配置文件canal-server/conf/example/instance.properties的内容

# ob server info
canal.instance.oceanbase.rsList=10.1.250.157:2882:2881,10.1.250.160:2882:2881
canal.instance.oceanbase.username=small_oa_test@neo_169
canal.instance.oceanbase.password=***
canal.instance.oceanbase.startTimestamp=0
canal.instance.oceanbase.clusterUrl=http://10.1.250.161:8080/services?Action=ObRootServiceInfo&ObCluster=myoceanbase
canal.instance.oceanbase.timezone=+8:00
canal.instance.oceanbase.workingMode=storage

# set extraConfigs for libobcdc, format {'key1': 'value1', 'key2': 'value2'}
canal.instance.oceanbase.obcdc.extraConfigs={'store_service_path': './storage'}

# ob log proxy info
canal.instance.oceanbase.logproxy.address=10.1.250.157:2983
canal.instance.oceanbase.logproxy.sslEnabled=false
canal.instance.oceanbase.logproxy.serverCert=../conf/${canal.instance.destination:}/ca.crt
canal.instance.oceanbase.logproxy.clientCert=../conf/${canal.instance.destination:}/client.crt
canal.instance.oceanbase.logproxy.clientKey=../conf/${canal.instance.destination:}/client.key
canal.instance.oceanbase.logproxy.clientId=

# tenant name
canal.instance.oceanbase.tenant=neo_169
# exclude tenant name in target schema name
canal.instance.parser.excludeTenantInDbName=true

# table regex, format: [tenant].[database].[table]
canal.instance.filter.regex=neo_169.small_oa_169.*
# table black regex
#canal.instance.filter.black.regex=mysql\\.slave_.*
# 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=example
# 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.mq.dynamicTopicPartitionNum=test.*:4,mycanal:6
#################################################

如下为配置文件canal-server/conf/canal.properties的内容:

#################################################
######### 		common argument		#############
#################################################
# tcp bind ip
canal.ip =
# register ip to zookeeper
canal.register.ip =
canal.port = 11111
canal.metrics.pull.port = 11112
# canal instance user/passwd
# canal.user = canal
# canal.passwd = E3619321C1A937C46A0D8BD1DAC39F93B27D4458

# canal admin config
#canal.admin.manager = 127.0.0.1:8089
canal.admin.port = 11110
canal.admin.user = admin
canal.admin.passwd = 4ACFE3202A5FF5CF467898FC58AAB1D615029441
# admin auto register
#canal.admin.register.auto = true
#canal.admin.register.cluster =
#canal.admin.register.name =

canal.zkServers = 127.0.0.1:2181
# flush data to zk
canal.zookeeper.flush.period = 1000
canal.withoutNetty = false
# tcp, kafka, rocketMQ, rabbitMQ, pulsarMQ
canal.serverMode = tcp
# 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
## meory store gets mode used MEMSIZE or ITEMSIZE
canal.instance.memory.batch.mode = MEMSIZE
canal.instance.memory.rawEntry = true

## detecing config
canal.instance.detecting.enable = false
#canal.instance.detecting.sql = insert into retl.xdual values(1,now()) on duplicate key update x=now()
canal.instance.detecting.sql = select 1
canal.instance.detecting.interval.time = 3
canal.instance.detecting.retry.threshold = 3
canal.instance.detecting.heartbeatHaEnable = false

# support maximum transaction size, more than the size of the transaction will be cut into multiple transactions delivery
canal.instance.transaction.size =  1024
# mysql fallback connected to new master should fallback times
canal.instance.fallbackIntervalInSeconds = 60

# network config
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 = false
canal.instance.filter.query.dml = false
# false
canal.instance.filter.query.ddl = true
canal.instance.filter.table.error = false
canal.instance.filter.rows = false
canal.instance.filter.transaction.entry = false
canal.instance.filter.dml.insert = false
canal.instance.filter.dml.update = false
canal.instance.filter.dml.delete = false

# binlog format/image check
canal.instance.binlog.format = ROW,STATEMENT,MIXED
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 = true
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

#################################################
######### 		destinations		#############
#################################################
canal.destinations = example
# conf root dir
canal.conf.dir = ../conf
# auto scan instance dir add/remove and start/stop instance
canal.auto.scan = true
canal.auto.scan.interval = 5
# set this value to 'true' means that when binlog pos not found, skip to latest.
# WARN: pls keep 'false' in production env, or if you know what you want.
canal.auto.reset.latest.pos.mode = false

canal.instance.tsdb.spring.xml = classpath:spring/tsdb/h2-tsdb.xml
#canal.instance.tsdb.spring.xml = classpath:spring/tsdb/mysql-tsdb.xml

canal.instance.global.mode = spring
canal.instance.global.lazy = false
canal.instance.global.manager.address = ${canal.admin.manager}
#canal.instance.global.spring.xml = classpath:spring/memory-instance.xml
#canal.instance.global.spring.xml = classpath:spring/file-instance.xml
canal.instance.global.spring.xml = classpath:spring/ob-default-instance.xml

##################################################
######### 	      MQ Properties      #############
##################################################
# aliyun ak/sk , support rds/mq
canal.aliyun.accessKey =
canal.aliyun.secretKey =
canal.aliyun.uid=

canal.mq.flatMessage = true
canal.mq.canalBatchSize = 50
canal.mq.canalGetTimeout = 100
# Set this value to "cloud", if you want open message trace feature in aliyun.
canal.mq.accessChannel = local

canal.mq.database.hash = true
canal.mq.send.thread.size = 30
canal.mq.build.thread.size = 8

##################################################
######### 		     Kafka 		     #############
##################################################
kafka.bootstrap.servers = 127.0.0.1:9092
kafka.acks = all
kafka.compression.type = none
kafka.batch.size = 16384
kafka.linger.ms = 1
kafka.max.request.size = 1048576
kafka.buffer.memory = 33554432
kafka.max.in.flight.requests.per.connection = 1
kafka.retries = 0

kafka.kerberos.enable = false
kafka.kerberos.krb5.file = "../conf/kerberos/krb5.conf"
kafka.kerberos.jaas.file = "../conf/kerberos/jaas.conf"

##################################################
######### 		    RocketMQ	     #############
##################################################
rocketmq.producer.group = test
rocketmq.enable.message.trace = false
rocketmq.customized.trace.topic =
rocketmq.namespace =
rocketmq.namesrv.addr = 127.0.0.1:9876
rocketmq.retry.times.when.send.failed = 0
rocketmq.vip.channel.enabled = false
rocketmq.tag =

##################################################
######### 		    RabbitMQ	     #############
##################################################
rabbitmq.host =
rabbitmq.virtual.host =
rabbitmq.exchange =
rabbitmq.username =
rabbitmq.password =
rabbitmq.deliveryMode =


##################################################
######### 		      Pulsar         #############
##################################################
pulsarmq.serverUrl =
pulsarmq.roleToken =
pulsarmq.topicTenantPrefix =

如下为canal-adapter的配置文件canal-for-ob/conf/rdb/application.yml的内容

## Mirror schema synchronize config
dataSourceKey: defaultDS
destination: example
groupId: g1
outerAdapterKey: mysql1
concurrent: true
dbMapping:
  database: small_oa_169 #需要同步的数据库名,两台服务器的数据库名最好命名成一样的,不然可能有各种意外情况发生
  table: t_product_stock_detail_snapshot #需要同步的表名
  targetTable: t_product_stock_detail_snapshot #同步到目标服务器对应的表名
  targetPk:
    id: id # 主键,格式为, 源表主键名:目标表主键名
  mapAll: true
mirrorDb: true
database: small_oa_169

如下为canal-for-ob/logs/adapter/adapter.log日志内容

在此处键入或粘贴代码
1 个赞

adapter 的日志没贴上,canal-for-ob/conf/rdb/application.yml 这个文件配置有点问题,整库同步和单表同步只能二选一,不能都配置。

另外我注意到文档里的 canal-for-ob 是比较旧的版本,现在可以用更新的安装包了 Release canal-for-ob-1.1.7-alpha · oceanbase/canal · GitHub

现在已经部署了最新的版本1.1.7-alpha了,deployer的日志有一个报错:

2024-03-22 15:39:14.905 [main] DEBUG c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Properties resource not found: class path resource [instance.properties] cannot be opened because it does not exist
2024-03-22 15:39:15.646 [main] INFO  c.a.o.c.p.inbound.mysql.tsdb.DefaultTableMetaTSDBFactory - oceanbase-neo-169 init TableMetaTSDB with classpath:spring/tsdb/h2-tsdb.xml
2024-03-22 15:39:15.649 [main] WARN  c.alibaba.otter.canal.parse.inbound.AbstractBinlogParser - --> init table filter : ^small_oa_169.t_product_stock_detail$|^small_oa_169.t_product_stock$
2024-03-22 15:39:15.649 [main] WARN  c.alibaba.otter.canal.parse.inbound.AbstractBinlogParser - --> init table black filter :
2024-03-22 15:39:15.653 [main] INFO  c.a.otter.canal.instance.core.AbstractCanalInstance - start successful....
2024-03-22 15:39:15.653 [main] INFO  c.a.otter.canal.server.embedded.CanalServerWithEmbedded - start CanalInstances[oceanbase-neo-169] successfully
2024-03-22 15:39:15.657 [destination = oceanbase-neo-169 , address = null , EventParser] ERROR c.a.o.c.p.inbound.mysql.rds.RdsBinlogEventParserProxy - parse events has an error
com.alibaba.otter.canal.parse.exception.CanalParseException: illegal connection is null
2024-03-22 15:58:52.445 [New I/O server worker #1-1] INFO  c.a.otter.canal.server.embedded.CanalServerWithEmbedded - subscribe successfully, ClientIdentity[destination=oceanbase-neo-169,clientId=1001,filter=] with first position:null

canal-for-ob/conf/rdb/application.yml这个配置文件的内容如下:

dataSourceKey: defaultDS
destination: oceanbase-neo-169
groupId: g1
outerAdapterKey: mysql1
concurrent: true
dbMapping:
  database: small_oa_169
  table: t_product_stock_detail
  targetTable: t_product_stock_detail
  targetPk:
    id: id
  mapAll: true
  #  targetColumns:
  #  id:
  #  name:
  #  role_id:
  #  c_time:
  #  test1:
  # etlCondition: "where c_time>={}"
  commitBatch: 3000 # 批量提交的大小


## Mirror schema synchronize config
#dataSourceKey: defaultDS
#destination: example
#groupId: g1
#outerAdapterKey: mysql1
#concurrent: true
#dbMapping:
#  mirrorDb: true
#  database: mytest