已解决 如何在canal-adapter 中多源解析配置
-
canal-server中配置多个源(5.7、8.0的mysql),配置同步到es,不知道canal-adapter中如何配置多个srcDataSources、canalAdapters 和group ?
-
需要不同服务器安装adapter
-
@流转的时光 对应一个instance,只写一个~
-
@cloudcanal-万少 在 如何在canal-adapter 中多源解析配置 中说:
canalAdapters:
- instance: example # canal instance Name or mq topic name
groups:- groupId: g1
outerAdapters:- name: logger
- groupId: g1
我每个source有一个instance,是否是
canalAdapters:
- instance: instance1,instance2 这样配置吗
groups:- groupId: g1
outerAdapters:- name: logger
- groupId: g1
- instance: example # canal instance Name or mq topic name
-
@流转的时光 一个adapter对应一个instance,一个instance下你可以配置多个group. application.yml可以参照官方的配置调整下:
- 先在adapter配置下使用es adapter
canal.conf: mode: tcp canalServerHost: 192.168.1.66:11111 batchSize: 500 syncBatchSize: 1000 retries: 0 timeout: accessKey: secretKey: srcDataSources: defaultDS: url: jdbc:mysql://192.168.1.66:3306/test?useUnicode=true username: root password: 123456 defaultDS2: url: jdbc:mysql://192.168.1.66:3307/test?useUnicode=true username: root password: 123456 canalAdapters: - instance: example # canal instance Name or mq topic name groups: - groupId: g1 outerAdapters: - name: logger - name: es hosts: 192.168.1.66:9300 # 127.0.0.1:9200 for rest mode properties: mode: transport # or rest cluster.name: docker-cluster
- es目录下需要多个订阅就配置多份配置,参考如下一份配置
dataSourceKey: defaultDS destination: example groupId: g1 esMapping: _index: mytest_user _type: doc _id: _id upsert: true # pk: id sql: "SELECT a.id as _id,a.name,a.age,a.update_time from stu_info a" # objFields: # _labels: array:; etlCondition: "where a.update_time>={}" commitBatch: 3000
-
另外请问下adapter端配置了多个dataSourceKey,那么instance和groupid 该怎么配置多个呢
-
server侧配置多个destination就有个多个订阅的实例了,多个实例的数据可以都写入到mq中。srcDataSources下面可以配置多个dataSourceKey
srcDataSources: defaultDS: url: jdbc:mysql://127.0.0.1:3306/mytest?useUnicode=true username: root password: 121212 defaultDS2: url: jdbc:mysql://127.0.0.1:3307/mytest?useUnicode=true username: root password: 121213
canalAdapters的配置参照官方文档ES相关内容即可:https://github.com/alibaba/canal/wiki/Sync-ES
Copyright © 2020 ClouGence, Inc.备案号:浙ICP备20007605号-2