批次過期
MinIO 版本新增:RELEASE.2023-12-02T10-51-33Z
MinIO 批次框架允許您使用 YAML 格式的作業定義檔案(「批次檔案」)建立、管理、監控和執行作業。批次作業直接在 MinIO 部署上執行,以利用伺服器端處理能力,而不會受到執行 MinIO 用戶端 的本機機器的限制。
expire
批次作業會將 自動物件過期 行為套用至單個儲存桶。作業會根據提供的組態決定過期資格,而與任何已設定的過期規則無關。
行為
立即過期物件
批次過期會立即發生,作為批次作業的一部分,相較於 基於被動掃描器的過期規則應用。具體來說,批次過期不會屈服於應用程式 I/O,並且可能會影響部署上常規讀取/寫入操作的效能。
在批次執行時決定過期資格
批次過期是針對每個儲存桶進行的,並且會執行一次以完成。作業會在作業執行時決定過期資格,並且 不會 定期重新掃描或重新檢查是否有新物件。
若要擷取任何符合過期資格的新物件,請重新執行批次作業。
過期規則僅檢查最新物件
批次過期作業僅會針對每個批次過期規則檢查每個物件的最新或「目前」版本。
過期批次作業參考
欄位 |
描述 |
|
必要 過期作業類型的最上層欄位。 |
|
必要 設定為 |
|
必要 指定作業在其內執行的儲存桶名稱。 |
|
選用 指定作業在其內執行的儲存桶前綴。 |
|
必要 要套用至指定 |
|
必要 支援以下兩個值之一
如需有關版本控制儲存桶中 |
|
選用 指定用於篩選物件的符合字串。 支援 glob 樣式萬用字元 ( |
|
選用 指定物件的年齡,以篩選物件。此規則僅適用於比指定時間單位更舊的物件。 例如, |
|
選用 指定 ISO-8601 時間戳記以篩選物件。 此規則僅適用於在指定時間戳記之前建立的物件。 |
|
選用 指定一個鍵值對陣列,用於描述篩選物件時所使用的物件標籤。 例如,以下範例會將規則篩選為僅適用於具有相符標籤的物件 tags:
- key: archive
value: True
此鍵與 |
|
選用 指定一個鍵值對陣列,用於描述篩選物件時所使用的物件元數據。 例如,以下範例會將規則篩選為僅適用於具有相符元數據的物件 metadata:
- key: content-type
value: image/*
此鍵與 |
|
選用 指定用於篩選物件的物件大小範圍。
|
|
選用 指定套用過期時要保留的物件版本數量。 預設值為 |
|
選用 用於傳送通知事件的預定義端點。 |
|
選用 用於存取 |
|
選用 放棄批次作業之前要完成的嘗試次數。 |
|
選用 每次嘗試之間要等待的時間量 ( |
用於 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