Ceph 对象存储多站点复制系列。第六部分
IBM Storage Ceph 对象存储多站点复制系列 第六部分 ¶
在这一系列之前的文章中,我们讨论了多站点同步策略,并分享了细粒度桶双向复制的动手示例。 在今天的博客中,第六部分,我们将配置额外的多站点同步策略,包括单向复制,从一个源到多个目标桶。
单向桶同步 ¶
在上一篇文章中,我们探讨了具有双向配置的桶同步策略。 现在让我们探讨一个如何启用两个桶之间单向同步的示例。 再次为了提供一些上下文,我们当前将我们的区域组同步策略设置为 allowed,并且在 zonegroup 级别配置了双向流。 借助区域组同步策略允许我们在每个桶粒度上配置复制,我们可以从我们的单向复制配置开始。

我们创建单向桶,然后创建一个 ID 为 unidirectional-1 的同步组,然后将状态设置为 Enabled。 当我们将同步组策略的状态设置为 enabled 时,一旦将管道应用于桶,复制将开始。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 mb s3://unidirectional
make_bucket: unidirectional
[root@ceph-node-00 ~]# radosgw-admin sync group create --bucket=unidirectional --group-id=unidirectiona-1 --status=enabled
一旦同步组就位,我们需要为我们的桶创建一个管道。 在此示例中,我们指定源区域和目标区域:源将是 zone1,目标是 zone2。 这样,我们就为桶 unidirectional 创建了一个单向复制管道,数据仅在一个方向复制:zone1 —> zone2。
[root@ceph-node-00 ~]# radosgw-admin sync group pipe create --bucket=unidirectional --group-id=unidirectiona-1 --pipe-id=test-pipe1 --source-zones='zone1' --dest-zones='zone2'
使用 sync info,我们可以检查桶复制的流程。 您可以看到 sources 字段为空,因为我们正在从 zone1 中的节点运行该命令,并且我们没有从外部源接收数据。 毕竟,从我们运行命令的区域来看,我们正在执行单向复制,因此我们正在将数据发送到目标区域。 我们可以看到,对于 unidirectional 桶,源是 zone1,目标是 zone2。
[root@ceph-node-00 ~]# radosgw-admin sync info --bucket unidirectional
{
"sources": [],
"dests": [
{
"id": "test-pipe1",
"source": {
"zone": "zone1",
"bucket": "unidirectional:89c43fae-cd94-4f93-b21c-76cd1a64788d.34955.1"
},
"dest": {
"zone": "zone2",
"bucket": "unidirectional:89c43fae-cd94-4f93-b21c-76cd1a64788d.34955.1"
….
}
当我们在 zone2 中运行相同的命令时,我们看到相同的信息,但 sources 字段显示从 zone1 接收数据。 单向桶 zone2 不会发送任何复制数据,这就是 sync info 命令输出中 destination 字段为空的原因。
[root@ceph-node-04 ~]# radosgw-admin sync info --bucket unidirectional
{
"sources": [
{
"id": "test-pipe1",
"source": {
"zone": "zone1",
"bucket": "unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
},
"dest": {
"zone": "zone2",
"bucket": "unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
},
….
"dests": [],
一旦我们的配置准备好投入使用,让我们做一些检查,看看一切是否按预期工作。 让我们将三个文件 PUT 到 zone1
[root@ceph-node-00 ~]# for i [1..3] do ; in aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 cp /etc/hosts s3://unidirectional/fil${i}
upload: ../etc/hosts to s3://unidirectional/fil1
upload: ../etc/hosts to s3://unidirectional/fil2
upload: ../etc/hosts to s3://unidirectional/fil3
我们可以检查它们是否已同步到 zone2
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://unidirectional/
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
现在让我们检查一下,如果我们向 zone2 PUT 一个对象会发生什么。 我们不应该看到该文件复制到 zone1,因为我们的桶复制配置是单向的。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 cp /etc/hosts s3://unidirectional/fil4
upload: ../etc/hosts to s3://unidirectional/fil4
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://unidirectional/
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
2024-02-02 17:57:49 233 fil4
我们稍后在 zone1 中检查,可以看到文件不在那里,这意味着它没有从 zone2 复制过来,正如预期的那样。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://unidirectional
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3

在此示例中,我们将通过添加一个名为 backupbucket 的新复制目标桶来修改先前的单向同步策略。 一旦设置了同步策略,上传到 zone1 中桶 unidirectional 的每个对象都将被复制到 zone2 中的桶 unidirectional 和 backupbucket。
首先,让我们创建桶 backupbucket
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 mb s3://backupbucket
make_bucket: backupbucket
我们将向我们现有的同步组策略添加一个名为 backupbucket 的新管道。 我们在之前的 unidirectional 示例中创建了组同步策略。
同样,我们指定源区域和目标区域,因此我们的同步将是单向的。 主要区别在于,现在我们使用 --dest-bucket 参数指定一个名为 backupbucket 的目标桶。
[root@ceph-node-00 ~]# radosgw-admin sync group pipe create --bucket=unidirectional --group-id=unidirectiona-1 --pipe-id=test-pipe2 --source-zones='zone1' --dest-zones='zone2' --dest-bucket=backupbucket
再次,让我们检查 sync info 输出,它向我们展示了我们配置的复制流程的表示。 sources 字段为空,因为在 zone1 中,我们没有从任何其他源接收数据。 在 destinations 中,我们现在有两个不同的 pipes。 第一个 test-pipe1 我们在之前的示例中创建了它。 第二个管道将 backupbucket 设置为 zone2 中的复制目标。
[root@ceph-node-00 ~]# radosgw-admin sync info --bucket unidirectional
{
"sources": [],
"dests": [
{
"id": "test-pipe1",
"source": {
"zone": "zone1",
"bucket": "unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
},
"dest": {
"zone": "zone2",
"bucket": "unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
},
"params": {
"source": {
"filter": {
"tags": []
}
},
"dest": {},
"priority": 0,
"mode": "system",
"user": "user1"
}
},
{
"id": "test-pipe2",
"source": {
"zone": "zone1",
"bucket": "unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
},
"dest": {
"zone": "zone2",
"bucket": "backupbucket"
},
"params": {
"source": {
"filter": {
"tags": []
}
},
"dest": {},
"priority": 0,
"mode": "system",
"user": "user1"
}
}
],
"hints": {
"sources": [],
"dests": [
"backupbucket"
]
},
让我们检查一下:从我们之前的示例中,我们有 zone1 中有三个文件
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://unidirectional/
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
在 zone2 中有四个文件,fil4 将不会复制到 zone1,因为复制是单向的。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://unidirectional/
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
2024-02-02 17:57:49 233 fil4
让我们向 zone1 添加三个文件。 我们预计这些文件将被复制到 zone2 中的 unidirectional 桶和 backupbucket
[root@ceph-node-00 ~]# for i [5..7] do ; in aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 cp /etc/hosts s3://unidirectional/fil${i}
upload: ../etc/hosts to s3://unidirectional/fil5
upload: ../etc/hosts to s3://unidirectional/fil6
upload: ../etc/hosts to s3://unidirectional/fil7
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://unidirectional
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
2024-02-02 18:03:51 233 fil5
2024-02-02 18:04:37 233 fil6
2024-02-02 18:09:08 233 fil7
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 ls s3://unidirectional
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
2024-02-02 17:57:49 233 fil4
2024-02-02 18:03:51 233 fil5
2024-02-02 18:04:37 233 fil6
2024-02-02 18:09:08 233 fil7
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 ls s3://backupbucket
2024-02-02 17:56:09 233 fil1
2024-02-02 17:56:10 233 fil2
2024-02-02 17:56:11 233 fil3
2024-02-02 18:03:51 233 fil5
2024-02-02 18:04:37 233 fil6
2024-02-02 18:09:08 233 fil7
太好了,一切都按预期工作。 我们所有的对象都复制到了所有的桶——除了 fil4。 这是预期的,因为该文件上传到 zone2,而我们的复制是单向的,因此没有从 zone2 到 zone1 的同步。
如果我们查询 backupbucket,sync info 会告诉我们什么? 此桶仅在另一个桶策略中引用,但桶 backupbucket 自身没有同步策略
[root@ceph-node-00 ~]# ssh ceph-node-04 radosgw-admin sync info --bucket backupbucket
{
"sources": [],
"dests": [],
"hints": {
"sources": [
"unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
],
"dests": []
},
"resolved-hints-1": {
"sources": [
{
"id": "test-pipe2",
"source": {
"zone": "zone1",
"bucket": "unidirectional:66df8c0a-c67d-4bd7-9975-bc02a549f13e.36430.1"
},
"dest": {
"zone": "zone2",
"bucket": "backupbucket"
},
对于这种情况,我们使用 hints,即使备份不直接参与 unidirectional 桶同步策略,它也会被一个 hint 引用。
请注意,在输出中,我们有 resolved hints,这意味着桶 backupbucket 找到了关于桶 unidirectional 同步到它的信息,但不是通过它自己的策略:backupbucket 的策略本身是空的。
桶同步策略注意事项 ¶
一个重要的注意事项,可能会有点令人困惑的是,元数据始终同步到其他区域,而与桶同步策略无关,因此每个用户和桶,即使未配置复制,也会出现在属于区域组的所有区域中。
举个例子,让我们创建一个名为 newbucket 的新桶
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 mb s3://newbucket
make_bucket: newbucket
我们确认此桶没有配置任何复制
[root@ceph-node-00 ~]# radosgw-admin bucket sync checkpoint --bucket newbucket
Sync is disabled for bucket newbucket
但是所有元数据都同步到辅助区域,因此该桶将出现在 zone2 中。 无论如何,桶内的data不会被复制。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls | grep newbucket
2024-02-02 02:22:31 newbucket
另一个需要注意的事项是,在为桶配置同步策略之前上传的对象不会自动同步到其他区域,直到我们在启用桶同步后上传一个对象。 此示例在上传新对象时同步
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://objectest1/
2024-02-02 04:03:47 233 file1
2024-02-02 04:03:50 233 file2
2024-02-02 04:03:53 233 file3
2024-02-02 04:27:19 233 file4
[root@ceph-node-00 ~]# ssh ceph-node-04 radosgw-admin bucket sync checkpoint --bucket objectest1
2024-02-02T04:17:15.596-0500 7fc00c51f800 1 waiting to reach incremental sync..
2024-02-02T04:17:17.599-0500 7fc00c51f800 1 waiting to reach incremental sync..
2024-02-02T04:17:19.601-0500 7fc00c51f800 1 waiting to reach incremental sync..
2024-02-02T04:17:21.603-0500 7fc00c51f800 1 waiting to reach incremental sync..
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 cp /etc/hosts s3://objectest1/file4
upload: ../etc/hosts to s3://objectest1/file4
[root@ceph-node-00 ~]# radosgw-admin bucket sync checkpoint --bucket objectest1
2024-02-02T04:27:29.975-0500 7fce4cf11800 1 bucket sync caught up with source:
local status: [00000000001.569.6, , 00000000001.47.6, , , , 00000000001.919.6, 00000000001.508.6, , , ]
remote markers: [00000000001.569.6, , 00000000001.47.6, , , , 00000000001.919.6, 00000000001.508.6, , , ]
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://objectest1
2024-02-02 04:03:47 233 file1
2024-02-02 04:03:50 233 file2
2024-02-02 04:03:53 233 file3
2024-02-02 04:27:19 233 file4
当桶同步策略处于 allowed 或 forbidden 状态时创建、修改或删除的对象不会在重新启用策略后自动同步。
我们需要运行 bucket sync run 命令来同步这些对象,并使两个区域中的桶保持同步。 例如,我们禁用了桶 objectest1 的同步,并将几个对象 PUT 到 zone1 中,这些对象在重新启用复制后不会复制到 zone2。
[root@ceph-node-00 ~]# radosgw-admin sync group create --bucket=objectest1 --group-id=objectest1-1 --status=forbidden
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 cp /etc/hosts s3://objectest1/file5
upload: ../etc/hosts to s3://objectest1/file5
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 cp /etc/hosts s3://objectest1/file6
upload: ../etc/hosts to s3://objectest1/file6
[root@ceph-node-00 ~]# radosgw-admin sync group create --bucket=objectest1 --group-id=objectest1-1 --status=enabled
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 ls s3://objectest1
2024-02-02 04:03:47 233 file1
2024-02-02 04:03:50 233 file2
2024-02-02 04:03:53 233 file3
2024-02-02 04:27:19 233 file4
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://objectest1/
2024-02-02 04:03:47 233 file1
2024-02-02 04:03:50 233 file2
2024-02-02 04:03:53 233 file3
2024-02-02 04:27:19 233 file4
2024-02-02 04:44:45 233 file5
2024-02-02 04:45:38 233 file6
要使桶再次同步,我们从目标区域使用 radosgw-admin sync run 命令。
[root@ceph-node-00 ~]# ssh ceph-node-04 radosgw-admin bucket sync run --source-zone zone1 --bucket objectest1
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 ls s3://objectest1
2024-02-02 04:03:47 233 file1
2024-02-02 04:03:50 233 file2
2024-02-02 04:03:53 233 file3
2024-02-02 04:27:19 233 file4
2024-02-02 04:44:45 233 file5
2024-02-02 04:45:38 233 file6
总结与下一步 ¶
我们继续在这一系列的第六部分中讨论多站点同步策略。 我们分享了一些配置多站点同步策略的动手示例,包括从一个源到多个目标桶的单向复制。 在本系列的最后一篇文章中,我们将介绍 Archive Zone 功能,该功能维护了来自我们的生产区域的所有对象的所有版本的不可变副本。
脚注 ¶
作者谨此感谢 IBM 对社区的支持,通过促使我们有时间创建这些帖子。