xfg-dev-tech-canal-docker-compose.yml 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
# 命令执行 docker-compose -f xfg-dev-tech-canal-docker-compose.yml up -d
version: '3.9'
services:
  mysql:
    image: mysql:8.0.32
    container_name: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 123456
    depends_on:
      - mysql-job-dbdata
    ports:
      - "13306:3306"
    volumes:
      - ./mysql/my.cnf:/etc/mysql/conf.d/mysql.cnf:ro
      - ./mysql/sql:/docker-entrypoint-initdb.d
    volumes_from:
      - mysql-job-dbdata
    networks:
      - default

  # 自动加载数据
  mysql-job-dbdata:
    image: alpine:3.18.2
    container_name: mysql-job-dbdata
    volumes:
      - /var/lib/mysql

  # phpmyadmin https://hub.docker.com/_/phpmyadmin
  phpmyadmin:
    image: phpmyadmin:5.2.1
    container_name: phpmyadmin
    hostname: phpmyadmin
    ports:
      - 8899:80
    environment:
      - PMA_HOST=mysql
      - PMA_PORT=3306
      - MYSQL_ROOT_PASSWORD=123456
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - default

  # canal-server 伪装成mysql的从库
  # docker cp canal-server:/home/admin/canal-server/conf/example/instance.properties /Users/xiaofuge/Documents/develop/github/xfg-studio/xfg-dev-tech-canal/docs/dev-ops/canal
  canal-server:
    image: canal/canal-server:v1.1.7
    container_name: canal-server
    restart: unless-stopped
    ports:
      - "11111:11111"
    volumes:
      - ./canal/instance.properties:/home/admin/canal-server/conf/example/instance.properties
    depends_on:
      - mysql
    networks:
      - default

  # canal-adapter 负责数据分发
  # docker cp canal-adapter:/opt/canal-adapter/conf/application.yml /Users/xiaofuge/Documents/develop/github/xfg-studio/xfg-dev-tech-canal/docs/dev-ops/canal-adapter
  # docker cp canal-adapter:/opt/canal-adapter/conf/rdb/mytest_user.yml /Users/xiaofuge/Documents/develop/github/xfg-studio/xfg-dev-tech-canal/docs/dev-ops/canal-adapter/rdb
  canal-adapter:
    image: coopersoft/canal-adapter:v1.1.6
    container_name: canal-adapter
    restart: unless-stopped
    ports:
      - "8082:8081"
    volumes:
      - ./canal-adapter/application.yml:/opt/canal-adapter/conf/application.yml
      - ./canal-adapter/es7:/opt/canal-adapter/conf/es7
    depends_on:
      - canal-server
    networks:
      - default

  elasticsearch:
    image: elasticsearch:7.17.14
    ports:
      - '9200:9200'
      - '9300:9300'
    container_name: elasticsearch
    restart: always
    environment:
      - 'cluster.name=elasticsearch' # 设置集群名称为elasticsearch
      - 'discovery.type=single-node' # 以单一节点模式启动
      - "cluster.name=docker-cluster" # 设置名称
      - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' # 设置使用jvm内存大小
    networks:
      - default

  kibana:
    image: kibana:7.17.14
    container_name: kibana
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime
      - ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    ports:
      - '5601:5601'
    links:
      - elasticsearch:es #可以用es这个域名访问elasticsearch服务
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200 #设置访问elasticsearch的地址
      - 'elasticsearch.hosts=http://es:9200' #设置访问elasticsearch的地址
      - I18N_LOCALE=zh-CN
    networks:
      - default
    depends_on:
      - elasticsearch

networks:
  default:
    driver: bridge