cronicle 后端存储是可配置的 ,通过使用不同的存储配置,我们可以解决多实例部署以及数据共享的问题
cronicle 的后端存储模型,设计的特别方便,包含了基于文件的,基于s3 的,同时我们也可以开发自己的
存储引擎

环境准备

  • docker-compose 文件
 
version: "3"
services:  
  s3:
      image: minio/minio
      command: server /data
      ports: 
      - "9000:9000"
      environment:
      - "MINIO_ACCESS_KEY=dalongapp"
      - "MINIO_SECRET_KEY=dalongapp"
      volumes: 
      - "./data:/data" 
  cronicle:
      build: ./
      hostname: master
      image: dalongrong/cronicle
      volumes:
      - "./config.json:/opt/cronicle/conf/config.json"
      ports:
      - "3012:3012"
  cronicle2:
      build: ./
      hostname: cronicle2
      image: dalongrong/cronicle
      volumes:
      - "./config.json:/opt/cronicle/conf/config.json"
      ports:
      - "3013:3012"
  cronicle3:
      build: ./
      hostname: cronicle3
      image: dalongrong/cronicle
      volumes:
      - "./config.json:/opt/cronicle/conf/config.json"
      ports:
      - "3014:3012"
  • cronicle dockerfile
    添加了aws sdk
 
FROM node:12.10.0-stretch-slim
LABEL AUTHOR="rongfengliang"
LABEL EMAIL="[email protected]"
RUN npm config set registry https://registry.npm.taobao.org
RUN curl -s https://raw.githubusercontent.com/jhuckaby/Cronicle/master/bin/install.js | node
RUN cd /opt/cronicle && npm install aws-sdk
EXPOSE 3012
ENTRYPOINT ["tail", "-f", "/dev/null"]
 
  • 存储配置
    config.json ,以下截取部分关于存储的配置
 
"Storage": {
    "engine": "S3",
    "AWS": {
      "accessKeyId": "dalongapp", 
      "secretAccessKey": "dalongapp", 
      "region": "us-east-1",
      "correctClockSkew": true,
      "endpoint": "s3:9000",
      "sslEnabled": false,
      "s3ForcePathStyle": true,
      "maxRetries": 5,
      "httpOptions": {
        "connectTimeout": 5000,
        "timeout": 5000
      }
    },
    "S3": {
      "keyPrefix": "cronicle",
      "fileExtensions": true,
      "params": {
        "Bucket": "cronicle"
      }
    }
  }

启动&&运行

  • 启动
docker-compose up -d
  • 创建s3桶
    通过UI
  • 启动master
docker-compose exec cronicle /opt/cronicle/bin/control.sh setup
docker-compose exec cronicle /opt/cronicle/bin/control.sh start
  • s3 内容

cronicle minio s3 存储配置集成-LMLPHP

  • 启动slave
docker-compose exec cronicle2 /opt/cronicle/bin/control.sh start
docker-compose exec cronicle3 /opt/cronicle/bin/control.sh start
  • 添加slave 节点

cronicle minio s3 存储配置集成-LMLPHP

  • 配置一个简单的调度任务

cronicle minio s3 存储配置集成-LMLPHP

  • 执行调度效果

cronicle minio s3 存储配置集成-LMLPHP

说明

以上是一个简单的基于minio s3 实现的配置共享,实际上基于s3 我们可以配置cronicle 的多master

参考资料

https://github.com/jhuckaby/Cronicle
https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/s3/s3_setcors.js
https://github.com/rongfengliang/cronicle-docker

05-27 19:56