github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/scripts/canal/docker/start.sh (about)

     1  #!/bin/sh
     2  
     3  # This script file uses enviroment variable to create config of canal adapter. The format of config file `application.yml`
     4  # is only suitable for canal adapter release version v1.1.5-alpha-2, if you want build from lastest master branch, please rewrite the
     5  # config file from canal/client-adapter/launcher/src/main/bin/conf/application.yml
     6  
     7  KAFKA_SERVER=${KAFKA_SERVER:-localhost:9092}
     8  ZOOKEEPER_SERVER=${ZOOKEEPER_SERVER:-localhost:2181}
     9  DB_NAME=${DB_NAME:-testdb}
    10  DOWNSTREAM_DB_HOST=${DOWNSTREAM_DB_HOST:-localhost}
    11  DOWNSTREAM_DB_PORT=${DOWNSTREAM_DB_PORT:-4000}
    12  echo "zookeeper server ${ZOOKEEPER_SERVER}"
    13  echo "kafka server ${KAFKA_SERVER}"
    14  echo "db name ${DB_NAME}"
    15  echo "downstream db host ${DOWNSTREAM_DB_HOST}"
    16  echo "downstream db port ${DOWNSTREAM_DB_PORT}"
    17  echo "use flatMessage: ${USE_FLAT_MESSAGE}"
    18  
    19  WORK_DIR=$(pwd)
    20  cat - >"${WORK_DIR}/conf/application.yml" <<EOF
    21  server:
    22    port: 8081
    23  spring:
    24    jackson:
    25      date-format: yyyy-MM-dd HH:mm:ss
    26      time-zone: GMT+8
    27      default-property-inclusion: non_null
    28  
    29  canal.conf:
    30    mode: kafka # tcp rocketMQ rabbitMQ
    31    flatMessage: ${USE_FLAT_MESSAGE}
    32    zookeeperHosts:
    33    syncBatchSize: 1000
    34    retries: 0
    35    timeout:
    36    accessKey:
    37    secretKey:
    38    consumerProperties:
    39      # kafka consumer
    40      kafka.bootstrap.servers: ${KAFKA_SERVER}
    41      kafka.enable.auto.commit: false
    42      kafka.auto.commit.interval.ms: 1000
    43      kafka.auto.offset.reset: latest
    44      kafka.request.timeout.ms: 40000
    45      kafka.session.timeout.ms: 30000
    46      kafka.isolation.level: read_committed
    47      kafka.max.poll.records: 1000
    48    canalAdapters:
    49    - instance: ${DB_NAME} # canal instance Name or mq topic name
    50      groups:
    51      - groupId: g1
    52        outerAdapters:
    53        - name: rdb
    54          key: mysql1
    55          properties:
    56            jdbc.driverClassName: com.mysql.jdbc.Driver
    57            jdbc.url: jdbc:mysql://${DOWNSTREAM_DB_HOST}:${DOWNSTREAM_DB_PORT}/${DB_NAME}
    58            jdbc.username: root
    59            jdbc.password:
    60  EOF
    61  
    62  cat - >"$WORK_DIR/conf/rdb/mytest_user.yml" <<EOF
    63  # Mirror schema synchronize config
    64  dataSourceKey: defaultDS
    65  destination: ${DB_NAME}
    66  groupId: g1
    67  outerAdapterKey: mysql1
    68  concurrent: true
    69  dbMapping:
    70    mirrorDb: true
    71    database: ${DB_NAME}
    72  EOF
    73  
    74  bash ./bin/startup.sh
    75  
    76  while true; do
    77    sleep 30000
    78  done