批量过期
在 MinIO 版本加入: RELEASE.2023-12-02T10-51-33Z
MinIO Batch Framework 允许您使用 YAML 格式的作业定义文件(即“批处理文件”)来创建、管理、监控和执行作业。 批处理作业直接在 MinIO 部署上运行,以利用服务器端的处理能力,而不会受到运行 MinIO 客户端 的本地机器的限制。
expire
批处理作业将 自动对象过期 行为应用于单个桶。
该作业根据提供的配置确定过期的资格,而与任何配置的过期规则无关。
行为
对象立即过期
批量过期作为批处理作业的一部分立即发生,与 基于扫描器的过期规则被动应用 相比。 特别是,批量过期不会让步于应用程序的 I/O,可能会影响部署上常规读/写操作的性能。
批量运行时确定到期资格
批次过期针对每个存储桶进行,并运行一次直至完成。 该作业在作业运行时确定过期的资格,并且不会定期重新扫描或重新检查新对象。
为了捕获任何可能有资格过期的新的对象,需要重新运行批处理作业。
过期规则仅检查最新对象
批量过期作业只检查每个对象的 “最新” 或 “当前” 版本是否符合每个批量过期规则。
过期批次处理工作参考
Field |
描述。 |
|
必需的 这是过期作业类型的顶级字段。 |
|
必需的 Set to |
|
必需的 指定作业运行的存储桶名称。 |
|
可选 指定作业运行的存储桶前缀。 |
|
必需的 一个数组,包含一个或多个要应用于指定 |
|
必需的 支持以下两个值之一:
有关版本化存储桶中 |
|
可选 指定一个匹配字符串用于过滤对象。 支持通配符风格的正则表达式( |
|
可选 指定过滤对象的对象年龄。 此规则仅适用于比指定时间单位更旧的那些对象。 例如, |
|
可选 为过滤对象指定 RFC3339 日期和时间。 此规则仅适用于在指定时间戳之前创建的对象。 |
|
可选 指定一个键值对数组,用以描述用于过滤对象的标签。
例如, 以下将规则过滤为仅具有匹配标签的对象: tags:
- key: archive
value: True
此键与 |
|
可选 指定一个键值对数组,用以描述用于过滤对象的元数据。
例如, 以下过滤器将规则限制为仅匹配具有匹配元数据的对象: metadata:
- key: content-type
value: image/*
此键与 |
|
可选 指定过滤对象的大小范围。
|
|
可选 指定在应用过期时保留的对象版本数量。 默认值为 |
|
可选 发送通知事件的自定义端点。 |
|
可选 一个可选的JSON Web Token(JWT),用于访问 |
|
可选 在放弃之前完成批量作业的尝试次数。 |
|
可选 每次尝试之间等待的时间( |
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