minio lifecycle 配置

尽管minio没有提供基于可视化界面的lifecycle 配置,但是也是支持对于bucket 对象策略的添加的

环境准备

version: '3.7'
services:
  sidekick:
    image: dalongrong/sidekick:v0.1.8
    tty: true
    ports:
    - "80:80"
    command: --health-path=/minio/health/ready --address :80 http://minio{1...4}:9000
  gateway:
    image: minio/minio:RELEASE.2020-04-04T05-39-31Z
    command: gateway s3 http://sidekick
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
    ports:
    - "9000:9000"
  minio1:
    image: minio/minio:RELEASE.2020-04-04T05-39-31Z
    volumes:
      - data1-1:/data1
      - data1-2:/data2
    ports:
      - "9001:9000"
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
      MINIO_BROWSER: "off"
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
  minio2:
    image: minio/minio:RELEASE.2020-04-04T05-39-31Z
    volumes:
      - data2-1:/data1
      - data2-2:/data2
    ports:
      - "9002:9000"
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
      MINIO_BROWSER: "off"
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
  minio3:
    image: minio/minio:RELEASE.2020-04-04T05-39-31Z
    volumes:
      - data3-1:/data1
      - data3-2:/data2
    ports:
      - "9003:9000"
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
      MINIO_BROWSER: "off"
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
  minio4:
    image: minio/minio:RELEASE.2020-04-04T05-39-31Z
    volumes:
      - data4-1:/data1
      - data4-2:/data2
    ports:
      - "9004:9000"
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
      MINIO_BROWSER: "off"
    command: server http://minio{1...4}/data{1...2}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3
volumes:
  data1-1:
  data1-2:
  data2-1:
  data2-2:
  data3-1:
  data3-2:
  data4-1:
  data4-2:

使用

  • 配置规则
    规则文件 bucket-lifecycle.json
 
{
    "Rules": [
        {
            "Expiration": {
                "Date": "2020-04-07T02:00:00.000Z"
            },
            "ID": "Delete very old messenger pictures",
            "Filter": {
                "Prefix": "uploads/2015/"
            },
            "Status": "Enabled"
        },
        {
            "Expiration": {
                "Days": 7
            },
            "ID": "Delete temporary uploads",
            "Filter": {
                "Prefix": "temporary-uploads/"
            },
            "Status": "Enabled"
        }
    ]
}
  • 启用规则
export AWS_ACCESS_KEY_ID="minio"
export AWS_SECRET_ACCESS_KEY="minio123"
aws s3api put-bucket-lifecycle-configuration --bucket apps --endpoint-url http://localhost --lifecycle-configuration file://bucket-lifecycle.json
  • 校验规则
    查看bucket 应用的生命周期规则
 
aws s3api get-bucket-lifecycle-configuration --bucket apps --endpoint-url http://localhost

参考资料

https://github.com/minio/minio/tree/master/docs/lifecycle
https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html

posted on 2020-04-07 09:55  荣锋亮  阅读(4680)  评论(3编辑  收藏  举报

导航