xiaoming728

xiaoming728

Docker部署Canal-adapter组件

Docker部署Canal-adapter组件

拉取源码

git clone https://github.com/returncode/canal.git

生成镜像

注意:编译用时很长

cd canal/client-adapter/docker
sh build.sh

运行容器

# cp配置文件
docker cp canal-adapter:/opt/canal-adapter/conf /home/docker/canal-adapter

# 启动容器
docker run -d -p 8081:8081 \
-v /home/docker/canal-adapter/conf:/opt/canal-adapter/conf \
-v /home/docker/canal-adapter/logs:/opt/canal-adapter/logs \
--name canal-adapter \
canal/canal-adapter:v1.1.6

应用配置

修改/conf/application.yml配置文件中的canal tcp consumer、数据源及instance和ES服务器地址

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: 0
  timeout:
  accessKey:
  secretKey:
  consumerProperties:
    # canal tcp consumer
    canal.tcp.server.host: 192.168.206.185:11111
    canal.tcp.zookeeper.hosts:
    canal.tcp.batch.size: 500
    canal.tcp.username:
    canal.tcp.password:
  srcDataSources:
    defaultDS:
      url: jdbc:mysql://192.168.206.180:3306/dev_archives_center?useUnicode=true
      username: canal
      password: linewell@123
  canalAdapters:
  - instance: dev # canal instance Name or mq topic name
    groups:
    - groupId: g1
      outerAdapters:
      - name: logger
      - name: es7
        hosts: 192.168.206.183:9300 # 127.0.0.1:9200 for rest mode
        properties:
          mode: transport # or rest
          # security.auth: test:123456 #  only used for rest mode
          cluster.name: docker-cluster

参考文献

https://www.jianshu.com/p/9be1f2125c08

https://www.jianshu.com/u/14b3dd246ec4