注意
本文档适用于 Ceph 开发版本。
云迁移
此功能允许将 S3 对象作为对象生命周期的一部分迁移到远程云服务通过. 迁移是单向的:数据不能从远程区域迁移回来。此功能的目的是启用数据迁移到多个云提供商。目前支持的云提供商是与 AWS (S3) 兼容的那些。存储类别. The transition is unidirectional: data cannot be transitioned back from the remote zone. The goal of this feature is to enable data transition to multiple cloud providers. The currently supported cloud providers are those that are compatible with AWS (S3).
使用一种特殊的层类型存储类cloud-s3
或cloud-s3-glacier
来配置要迁移到的远程云 S3 对象存储服务。这些是根据区域组放置目标定义的,与常规存储类不同,不需要数据池。
必须配置远程云对象存储服务的用户凭证。请注意,源 ACL 不会被保留。可以将特定源用户的权限映射到特定目标用户。
云存储类层类型
tier-type
(字符串)
将用于迁移对象的远程云服务的类型。以下层类型受支持:
cloud-s3
: 常规 S3 兼容对象存储服务cloud-s3-glacier
: S3 Glacier 或磁带存储服务
云存储类层级配置
{
"access_key": <access>,
"secret": <secret>,
"endpoint": <endpoint>,
"region": <region>,
"host_style": <path | virtual>,
"acls": [ { "type": <id | email | uri>,
"source_id": <source_id>,
"dest_id": <dest_id> } ... ],
"target_path": <target_path>,
"target_storage_class": <target-storage-class>,
"multipart_sync_threshold": {object_size},
"multipart_min_part_size": {part_size},
"retain_head_object": <true | false>
}
云迁移特定可配置项
access_key
(字符串)
远程云 S3 访问密钥。
secret
(字符串)
远程云 S3 服务的密钥。
endpoint
(字符串)
远程云 S3 服务的 URL。
region
(字符串)
远程云 S3 服务区域名称。
host_style
(路径 | 虚拟)
访问远程云 S3 服务时要使用的宿主样式(默认:600540: . 这些定义了对每个对象执行的 ACL 变更。ACL 变更使得可以将源用户 ID 转换为目标用户 ID。path
).
acls
(数组)
包含一个列表的acl_mappings
.
acl_mapping
(容器)
每个acl_mapping
结构包含type
, source_id
, and dest_id
. These
define the ACL mutation to be done on each object. An ACL mutation makes it possible to
convert a source userid to a destination userid.
type
(ID | 邮箱 | URI)
ACL 类型:id
定义用户 ID,email
通过电子邮件定义用户,uri
通过uri
(组) 定义用户。
source_id
(字符串)
源区域中的用户 ID。
dest_id
(字符串)
目标上的用户 ID。
target_path
(字符串)
一个定义目标路径如何构建的字符串。目标路径指定源存储桶名称/对象名称要附加的前缀。如果未指定,则target_path
创建的是rgwx-${zonegroup}-${storage-class}-cloud-bucket
.
例如:target_path = rgwx-archive-${zonegroup}/
target_storage_class
(字符串)
一个定义对象迁移到的目标存储类的字符串。如果未指定,对象将迁移到STANDARD
存储类。
retain_head_object
(true | false)
如果true
,迁移到云服务的对象元数据将保留。如果false
(默认),迁移后对象将被删除。此选项对当前版本的对象无效。有关更多详细信息,请参阅下文“版本化对象”部分。
S3 特定可配置项
目前,云迁移仅适用于与 AWS S3 协议兼容的后端。有几种可配置项可用于调整访问云服务时的行为:
{
"multipart_sync_threshold": {object_size},
"multipart_min_part_size": {part_size}
}
multipart_sync_threshold
(整数)
大小等于或大于此值的对象将使用多部分上传迁移到云端。
multipart_min_part_size
(整数)
使用多部分上传迁移对象时使用的最小部分大小。
如何配置
请参阅添加存储类如何为区域组配置存储类。云迁移需要一个具有层类型定义为cloud-s3
或cloud-s3-glacier
Note
如果您之前未执行多站点配置,则会为您创建一个区域和区域组,并且对区域/区域组的更改只有在重新启动 Ceph 对象网关(RGW 守护进程)后才会生效。如果您为多站点创建了区域,则区域/区域组更改一旦提交default
zone and zonegroup are created for you, and changes
to the zone/zonegroup will not take effect until the Ceph Object
Gateways (RGW daemons) are restarted. If you have created a realm for multisite,
the zone/zonegroup changes will take effect once the changes are
committed with radosgw-admin period update --commit
.
radosgw-admin zonegroup placement add --rgw-zonegroup={zone-group-name} \
--placement-id={placement-id} \
--storage-class={storage-class-name} \
--tier-type=cloud-s3
例如
radosgw-admin zonegroup placement add --rgw-zonegroup=default \
--placement-id=default-placement \
--storage-class=CLOUDTIER --tier-type=cloud-s3
[
{
"key": "default-placement",
"val": {
"name": "default-placement",
"tags": [],
"storage_classes": [
"CLOUDTIER",
"STANDARD"
],
"tier_targets": [
{
"key": "CLOUDTIER",
"val": {
"tier_type": "cloud-s3",
"storage_class": "CLOUDTIER",
"retain_head_object": "false",
"s3": {
"endpoint": "",
"access_key": "",
"secret": "",
"host_style": "path",
"target_storage_class": "",
"target_path": "",
"acl_mappings": [],
"multipart_sync_threshold": 33554432,
"multipart_min_part_size": 33554432
}
}
}
]
}
}
]
Note
一旦创建了层类型为--tier-type=cloud-s3
或--tier-type=cloud-s3-glacier
的存储类,它就不能稍后修改为任何其他存储类类型。
然后可以使用以下命令执行层配置:
radosgw-admin zonegroup placement modify --rgw-zonegroup={zone-group-name} \
--placement-id={placement-id} \
--storage-class={storage-class-name} \
--tier-config={key}={val}[,{key}={val}]
The key
中的配置指定要更新的配置变量,并且val
指定其新值。
例如:
radosgw-admin zonegroup placement modify --rgw-zonegroup default \
--placement-id default-placement \
--storage-class CLOUDTIER \
--tier-config=endpoint=http://XX.XX.XX.XX:YY,\
access_key=<access_key>,secret=<secret>, \
multipart_sync_threshold=44432, \
multipart_min_part_size=44432, \
retain_head_object=true
可以使用点来访问嵌套层配置值。这种表示法类似于在 JSON 中使用工具(如jq
. 请注意,使用点分隔符(.)
是在--tier-config
内部键访问中特定的,不应与 Ceph RGW 区域/区域组/区域的模式混淆。例如:
radosgw-admin zonegroup placement modify --rgw-zonegroup={zone-group-name} \
--placement-id={placement-id} \
--storage-class={storage-class-name} \
--tier-config=acls.source_id=${source-id}, \
acls.dest_id=${dest-id}
可以通过指定要引用的特定条目(用方括号括起来)来访问配置数组条目,并且可以使用空数组[]添加新的数组条目。例如,创建一个新的acl
数组条目:
radosgw-admin zonegroup placement modify --rgw-zonegroup={zone-group-name} \
--placement-id={placement-id} \
--storage-class={storage-class-name} \
--tier-config=acls[].source_id=${source-id}, \
acls[${source-id}].dest_id=${dest-id}, \
acls[${source-id}].type=email
可以通过提供--tier-config-rm={key}
.
例如:
radosgw-admin zonegroup placement modify --rgw-zonegroup default \
--placement-id default-placement \
--storage-class CLOUDTIER \
--tier-config-rm=acls.source_id=testid
radosgw-admin zonegroup placement modify --rgw-zonegroup default \
--placement-id default-placement \
--storage-class CLOUDTIER \
--tier-config-rm=target_path
来删除条目。可以使用以下命令删除存储类:
radosgw-admin zonegroup placement rm --rgw-zonegroup={zone-group-name} \
--placement-id={placement-id} \
--storage-class={storage-class-name}
例如:
radosgw-admin zonegroup placement rm --rgw-zonegroup default \
--placement-id default-placement \
--storage-class CLOUDTIER
[
{
"key": "default-placement",
"val": {
"name": "default-placement",
"tags": [],
"storage_classes": [
"STANDARD"
]
}
}
]
对象修改和限制
配置云存储类后,在定义存储桶生命周期(LC)规则时,可以使用任何其他存储类。例如:
<LifecycleConfiguration>
<Rule>
....
<Transition>
....
<StorageClass>CLOUDTIER</StorageClass>
</Transition>
</Rule>
</LifecycleConfiguration>
由于迁移是单向的,在配置 S3
由于 API 限制,没有办法保留原始对象修改时间和 ETag,这些作为元数据属性存储在目标对象上,如下所示:
x-amz-meta-rgwx-source: rgw
x-amz-meta-rgwx-source-etag: ed076287532e86365e841e92bfc50d8c
x-amz-meta-rgwx-source-key: lc.txt
x-amz-meta-rgwx-source-mtime: 1608546349.757100363
x-amz-meta-rgwx-versioned-epoch: 0
为了允许云服务检测源并映射用户定义的x-amz-meta-
属性,向正在迁移的对象添加了两个附加的新
x-rgw-cloud
:true
/false
true
,默认情况下,如果对象是从 RGW 迁移的。x-rgw-cloud-keep-attrs
:true
/false
如果设置为默认
true
,云服务应映射并存储所有the x-amz-meta-*
属性。如果它无法做到这一点,则操作应失败。如果设置为
false
,云服务可以忽略此类属性,只需存储发送的对象数据。
默认情况下,迁移后,源对象将被删除。但是,可以通过将配置选项storage-class
和object-size
。但是,对此类对象执行retain_head_object
设置为 true 来保留其元数据,包括GET
操作仍然会以InvalidObjectState
错误失败。对原始源对象进行的任何其他操作都仅针对其元数据条目,同时保留迁移后的对象。
例如:
s3cmd info s3://bucket/lc.txt
s3://bucket/lc.txt (object):
File size: 12
Last mod: Mon, 21 Dec 2020 10:25:56 GMT
MIME type: text/plain
Storage: CLOUDTIER
MD5 sum: ed076287532e86365e841e92bfc50d8c
SSE: none
Policy: none
CORS: none
ACL: M. Tester: FULL_CONTROL
x-amz-meta-s3cmd-attrs: atime:1608466266/ctime:1597606156/gid:0/gname:root/md5:ed076287532e86365e841e92bfc50d8c/mode:33188/mtime:1597605793/uid:0/uname:root
s3cmd get s3://bucket/lc.txt lc_restore.txt
download: 's3://bucket/lc.txt' -> 'lc_restore.txt' [1 of 1]
ERROR: S3 error: 403 (InvalidObjectState)
为了避免跨存储桶的对象名称冲突,将源存储桶名称添加到目标对象名称的前面。如果对象是版本化的,则将对象的versionid
添加到后面。
下面是对象名称格式:
s3://<target_path>/<source_bucket_name>/<source_object_name>(-<source_object_version_id>)
版本化对象
对于版本化和锁定的对象,应用与生命周期过期类似的语义,如下所述。
如果对象是当前的,迁移到云后,它将变为非当前并创建删除标记。
如果对象是非当前的并且被锁定,则其迁移将被跳过。
恢复对象
现在可以恢复迁移到云的对象。有关更多信息,请参阅从云恢复对象.
未来工作
发送预签名重定向或读取迁移到云的对象
在迁移到云的对象上支持 s3:RestoreObject 操作。
支持迁移到其他云提供商(如 Azure)。
由 Ceph 基金会带给您
Ceph 文档是一个社区资源,由非盈利的 Ceph 基金会资助和托管Ceph Foundation. 如果您想支持这一点和我们的其他工作,请考虑加入现在加入.