文件

批次過期

新版本: MinIO:RELEASE.2023-12-02T10-51-33Z

MinIO 批次框架可讓您使用 YAML 格式的工作定義檔案(「批次檔案」)建立、管理、監控和執行工作。批次工作直接在 MinIO 部署上執行,以利用伺服器端的處理能力,而無需受限於執行 MinIO 用戶端的本機。

expire 批次工作將 自動物件過期 行為套用到單個儲存貯體。此工作根據提供的配置判斷過期資格,而與任何已配置的過期規則無關。

行為

物件的立即過期

批次過期是作為批次工作的一部分立即發生的,而 被動掃描器應用程式過期規則則不同。具體來說,批次過期不會讓位於應用程式 I/O,並且可能會影響部署上常規讀/寫操作的效能。

在批次執行時判斷過期資格

批次過期是按儲存貯體進行,並執行一次直到完成。此工作在工作執行時判斷過期資格,並且不會定期重新掃描或重新檢查是否有新物件。

若要擷取任何符合過期資格的新物件,請重新執行批次工作。

過期規則僅檢查最新的物件

批次過期工作僅針對每個批次過期規則檢查每個物件的最新或「當前」版本。

過期批次工作參考

欄位

描述

expire

必要

過期工作類型的最上層欄位。

apiVersion

必要

設定為 v1

bucket

必要

指定工作執行所在的儲存貯體的名稱。

prefix

選用

指定工作執行所在的儲存貯體前綴。

rules

必要

要套用到指定 bucketprefix(如果有)中物件的一個或多個過期規則陣列。

rules.[n].type

必要

支援下列兩個值之一

  • object - 僅套用到當前版本不是 DeleteMarker 的物件。

  • deleted - 僅套用到當前版本 DeleteMarker 的物件。

請參閱 物件刪除,以取得關於版本化儲存貯體中 DeleteMarker 或刪除操作的更完整文件。

rules.[n].name

選用

指定用於篩選物件的匹配字串。

支援 glob 樣式的萬用字元 (*?)。

rules.[n].olderThan

選用

指定用於篩選物件的物件存在時間。此規則僅適用於存在時間長於指定時間單位的物件。

例如,72h3d 選擇存在時間長於三天的物件。

rules.[n].createdBefore

選用

指定用於篩選物件的 ISO-8601 時間戳記。

此規則僅適用於在指定時間戳記之前建立的物件。

rules.[n].tags

選用

指定用於篩選物件的物件標籤的鍵值對陣列。value 條目支援 glob 樣式的萬用字元 (*?)。

例如,以下設定會篩選規則,使其僅適用於具有相符標籤的物件

tags:
  - key: archive
    value: True

此鍵與 rules.[n].type: deleted 不相容。

rules.[n].metadata

選用

指定用於篩選物件的物件中繼資料的鍵值對陣列。value 鍵支援 glob 樣式的萬用字元 (*?)。

例如,以下設定會篩選規則,使其僅適用於具有相符中繼資料的物件

metadata:
  - key: content-type
    value: image/*

此鍵與 rules.[n].type: deleted 不相容。

rules.[n].size

選用

指定用於篩選物件的物件大小範圍。

  • lessThan - 比對大小小於指定數量的物件 (例如 MiBGiB)。

  • greaterThan - 比對大小大於指定數量的物件 (例如 MiBGiB)。

rules.[n].purge.retainVersions

選用

指定在套用過期時要保留的物件版本數量。

預設值為 0,用於刪除所有物件版本 (最快)。

notify.endpoint

選用

用於傳送通知事件的預定義端點。

notify.token

選用

用於存取 notify.endpoint 的選用 JSON Web Token (JWT)。

retry.attempts

選用

在放棄之前,完成批次工作的嘗試次數。

retry.delay

選用

每次嘗試之間等待的時間量 (ms)。

用於 expire 工作類型的範例 YAML 描述

使用 mc batch generate 建立基本的 expire 批次工作,以進行進一步的自訂。

expire:
  apiVersion: v1
  bucket: mybucket # Bucket where this job will expire matching objects from
  prefix: myprefix # (Optional) Prefix under which this job will expire objects matching the rules below.
  rules:
    - type: object  # objects with zero ore more older versions
      name: NAME # match object names that satisfy the wildcard expression.
      olderThan: 70h # match objects older than this value
      createdBefore: "2006-01-02T15:04:05.00Z" # match objects created before "date"
      tags:
        - key: name
          value: pick* # match objects with tag 'name', all values starting with 'pick'
      metadata:
        - key: content-type
          value: image/* # match objects with 'content-type', all values starting with 'image/'
      size:
        lessThan: 10MiB # match objects with size less than this value (e.g. 10MiB)
        greaterThan: 1MiB # match objects with size greater than this value (e.g. 1MiB)
      purge:
          # retainVersions: 0 # (default) delete all versions of the object. This option is the fastest.
          # retainVersions: 5 # keep the latest 5 versions of the object.

    - type: deleted # objects with delete marker as their latest version
      name: NAME # match object names that satisfy the wildcard expression.
      olderThan: 10h # match objects older than this value (e.g. 7d10h31s)
      createdBefore: "2006-01-02T15:04:05.00Z" # match objects created before "date"
      purge:
          # retainVersions: 0 # (default) delete all versions of the object. This option is the fastest.
          # retainVersions: 5 # keep the latest 5 versions of the object including delete markers.

  notify:
    endpoint: https://notify.endpoint # notification endpoint to receive job completion status
    token: Bearer xxxxx # optional authentication token for the notification endpoint

  retry:
    attempts: 10 # number of retries for the job before giving up
    delay: 500ms # least amount of delay between each retry