mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Updated ClientAdapter (markdown)
@@ -43,44 +43,33 @@ client-adapter分为适配器和启动器两部分, 适配器为多个fat jar,
|
||||
#### adapter定义配置部分
|
||||
```
|
||||
canal.conf:
|
||||
canalServerHost: 127.0.0.1:11111 # 对应单机模式下的canal server的ip:port
|
||||
zookeeperHosts: slave1:2181 # 对应集群模式下的zk地址, 如果配置了canalServerHost, 则以canalServerHost为准
|
||||
bootstrapServers: slave1:6667 # kafka或rocketMQ地址, 与canalServerHost不能并存
|
||||
flatMessage: true # 扁平message开关, 是否以json字符串形式投递数据, 仅在kafka/rocketMQ模式下有效
|
||||
canalInstances: # canal实例组, 如果是tcp模式可配置此项
|
||||
- instance: example # 对应canal destination
|
||||
groups: # 对应适配器分组, 分组间的适配器并行运行
|
||||
- outAdapters: # 适配器列表, 分组内的适配串行运行
|
||||
- name: logger # 适配器SPI名
|
||||
- name: hbase
|
||||
properties: # HBase相关连接参数
|
||||
hbase.zookeeper.quorum: slave1
|
||||
hbase.zookeeper.property.clientPort: 2181
|
||||
zookeeper.znode.parent: /hbase
|
||||
mqTopics: # MQ topic租, 如果是kafka或者rockeMQ模式可配置此项, 与canalInstances不能并存
|
||||
- mqMode: kafka # MQ的模式: kafak/rocketMQ
|
||||
topic: example # MQ topic
|
||||
groups: # group组
|
||||
- groupId: g2 # group id
|
||||
outAdapters: # 适配器列表, 以下配置和canalInstances中一样
|
||||
- name: logger
|
||||
canalServerHost: 127.0.0.1:11111 # 对应单机模式下的canal server的ip:port
|
||||
zookeeperHosts: slave1:2181 # 对应集群模式下的zk地址, 如果配置了canalServerHost, 则以canalServerHost为准
|
||||
mqServers: slave1:6667 #or rocketmq # kafka或rocketMQ地址, 与canalServerHost不能并存
|
||||
flatMessage: true # 扁平message开关, 是否以json字符串形式投递数据, 仅在kafka/rocketMQ模式下有效
|
||||
batchSize: 50 # 每次获取数据的批大小, 单位为K
|
||||
syncBatchSize: 1000 # 每次同步的批数量
|
||||
retries: 0 # 重试次数
|
||||
timeout: # 同步超时时间, 单位毫秒
|
||||
mode: tcp # kafka rocketMQ # canal client的模式: tcp kafka rocketMQ
|
||||
srcDataSources: # 源数据库
|
||||
defaultDS: # 自定义名称
|
||||
url: jdbc:mysql://127.0.0.1:3306/mytest?useUnicode=true # jdbc url
|
||||
username: root # jdbc 账号
|
||||
password: 121212 # jdbc 密码
|
||||
canalAdapters: # 适配器列表
|
||||
- instance: example # canal instance Name or mq topic name
|
||||
groups: # 分组列表
|
||||
- groupId: g1 # 分组id, 如果是MQ模式将用到该值
|
||||
outerAdapters: # 分组内适配器列表
|
||||
- name: logger # 日志打印适配器
|
||||
......
|
||||
```
|
||||
|
||||
说明:
|
||||
1. 一份数据可以被多个group同时消费, 多个group之间会是一个并行执行, 一个group内部是一个串行执行多个outAdapters, 比如例子中logger和hbase
|
||||
2. 目前client adapter数据订阅的方式支持两种,直连canal server 或者 订阅kafka/RocketMQ的消息, 一个client adapter进程里可以同时两种
|
||||
1. 一份数据可以被多个group同时消费, 多个group之间会是一个并行执行, 一个group内部是一个串行执行多个outerAdapters, 比如例子中logger和hbase
|
||||
2. 目前client adapter数据订阅的方式支持两种,直连canal server 或者 订阅kafka/RocketMQ的消息
|
||||
|
||||
#### adapter参数配置部分
|
||||
```
|
||||
adapter.conf:
|
||||
datasourceConfigs: # 数据源配置列表, 数据源将在适配器中用于ETL、数据同步回查等使用
|
||||
defaultDS: # 数据源 dataSourceKey, 适配器中通过该值获取指定数据源
|
||||
url: jdbc:mysql://127.0.0.1:3306/mytest?useUnicode=true
|
||||
username: root
|
||||
password: 121212
|
||||
adapterConfigs: # 适配器内部配置列表
|
||||
- hbase/mytest_person2.yml # 类型/配置文件名, 这里示例就是对应HBase适配器hbase目录下的mytest_person2.yml文件
|
||||
```
|
||||
|
||||
## 三、适配器启动
|
||||
|
||||
@@ -101,12 +90,17 @@ spring:
|
||||
|
||||
canal.conf:
|
||||
canalServerHost: 127.0.0.1:11111
|
||||
flatMessage: true
|
||||
canalInstances:
|
||||
- instance: example
|
||||
adapterGroups:
|
||||
- outAdapters:
|
||||
- name: logger
|
||||
batchSize: 500
|
||||
syncBatchSize: 1000
|
||||
retries: 0
|
||||
timeout:
|
||||
mode: tcp
|
||||
canalAdapters:
|
||||
- instance: example
|
||||
groups:
|
||||
- groupId: g1
|
||||
outerAdapters:
|
||||
- name: logger
|
||||
```
|
||||
|
||||
#### 3.1.3 启动
|
||||
@@ -169,6 +163,8 @@ curl http://127.0.0.1:8081/count/hbase/mytest_person2.yml
|
||||
|
||||
### ES适配器
|
||||
|
||||
同步关ES配置 : [[Sync-ES]]
|
||||
|
||||
### MongoDB适配器
|
||||
|
||||
### Redis适配器
|
||||
Reference in New Issue
Block a user