1.拉取镜像
docker pull slpcat/canal-adapter:v1.1.5
2.建立配置文件
mkdir -p /mydata/canal-adapter/conf
mkdir -p /mydata/canal-adapter/conf/es7
touch /mydata/canal-adapter/conf/application.yml
touch /mydata/canal-adapter/conf/es7ceshi.yml
3.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
flatMessage: true
zookeeperHosts:
syncBatchSize: 1000
retries: 0
timeout:
accessKey:
secretKey:
consumerProperties:
# canal tcp consumer
canal.tcp.server.host: canal-server地址:11111
canal.tcp.batch.size: 500
canal.tcp.username:
canal.tcp.password:
srcDataSources:
defaultDS:
url: jdbc:mysql://数据库IP:数据库端口/数据库名?useUnicode=true
username: db_username
password: db_password
canalAdapters:
- instance: example # canal instance Name or mq topic name
groups:
- groupId: g1
outerAdapters:
- name: logger
- name: es7 # 该版本发现只能是es7/es6
hosts: esip地址:9300 # 127.0.0.1:9200 for rest mode
properties:
mode: transport # transport # or rest
4.ceshi.yml文件(ps:名字随便起,同步多少个index就要有多少个文件)
dataSourceKey: defaultDS
destination: example
groupId: g1
esMapping:
_index: ceshi
_id: _id
_type: _doc
upsert: true
# pk: id
sql: "SELECT a.id _id from t_ceshi a "
# objFields:
# _labels: array:;
etlCondition: "where a.>={}"
commitBatch: 3000
5.创建并启动容器
docker run --name canal-adapter -p 8081:8081 \
-v /mydata/canal-adapter/conf:/opt/canal-adapter/conf \
-d slpcat/canal-adapter:v1.1.5
6.查看启动是否报错
docker logs canal-adapter
7.测试方法
随便更改一个t_ceshi表的内容