批量过期
New in version MinIO: RELEASE.2023-12-02T10-51-33Z
MinIO 批处理框架允许你使用 YAML 格式的作业定义文件(“batch file”)创建、管理、监控和执行作业。 批处理作业直接在 MinIO 部署上运行,从而利用服务端处理能力,而不受运行 MinIO Client 的本地机器限制。
expire 批处理作业会将 对象自动过期 的行为应用到单个存储桶。
该作业根据提供的配置判断对象是否符合过期条件,且独立于任何已配置的过期规则。
行为
对象立即过期
批量过期会作为批处理作业的一部分立即执行,这与 passive scanner-based application of expiration rules 不同。 具体来说,批量过期不会让位于应用 I/O,因此可能影响部署上常规读写操作的性能。
过期资格在批处理运行时确定
批量过期按存储桶工作,并且每次运行都会一次性执行直至完成。 该作业在运行时判断对象是否符合过期条件,并且*不会*定期重新扫描或重新检查新对象。
如果要处理任何新近满足过期条件的对象,请重新运行该批处理作业。
过期规则仅检查最新对象
批量过期作业只会使用每个对象的最新版本或“current”版本来匹配各条批量过期规则。
expire 批处理作业参考
字段 |
说明 |
|
必需 过期作业类型的顶层字段。 |
|
必需 设为 |
|
必需 指定该作业运行所在的存储桶名称。 |
|
可选 指定该作业运行所在的存储桶前缀。 |
|
必需 一个包含一条或多条过期规则的数组,用于应用到指定 |
|
必需 支持以下两个值之一:
有关 |
|
可选 指定用于过滤对象的匹配字符串。 支持 glob 风格通配符( |
|
可选 指定对象年龄以过滤对象。 该规则仅应用于年龄超过指定时间单位的对象。 例如, |
|
可选 指定一个 RFC3339 日期时间来过滤对象。 该规则仅应用于在指定时间戳*之前*创建的对象。 |
|
可选 指定一个键值对数组,用于描述对象标签并据此过滤对象。
例如,以下配置会将该规则过滤为仅匹配具有相应标签的对象: 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 this date and time in RFC3339 format
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 this date and time in RFC3339 format
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