Ceph 對(duì)象存儲(chǔ)多站點(diǎn)復(fù)制:將配置其他多站點(diǎn)同步策略
1.目標(biāo)
在今天的博客第六部分中,我們將配置其他多站點(diǎn)同步策略,包括從一個(gè)源到多個(gè)目標(biāo)存儲(chǔ)桶的單向復(fù)制。
2.單向桶同步
在上一篇文章中,我們探討了具有雙向配置的存儲(chǔ)桶同步策略。現(xiàn)在,讓我們通過一個(gè)示例來了解如何啟用兩個(gè)存儲(chǔ)桶之間的單向同步。在示例中,我們目前將區(qū)域組同步策略設(shè)置為allowed ,并在zonegroup級(jí)別配置了雙向流。通過區(qū)域組同步策略允許我們以每個(gè)存儲(chǔ)桶的粒度配置復(fù)制,我們可以從單向復(fù)制配置開始。
圖片
我們創(chuàng)建單向存儲(chǔ)桶,然后創(chuàng)建一個(gè) ID 為unidirectional-1同步組,然后將狀態(tài)設(shè)置為Enabled 。當(dāng)我們將同步組策略的狀態(tài)設(shè)置為enabled時(shí),一旦管道應(yīng)用到存儲(chǔ)桶,復(fù)制就會(huì)開始。
[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
一旦同步組就位,我們需要為我們的存儲(chǔ)桶創(chuàng)建一個(gè)管道。在此示例中,我們指定源區(qū)域和目標(biāo)區(qū)域:源為zone1 ,目標(biāo)為zone2 。這樣,我們就為bucket unidirectional創(chuàng)建了一個(gè)單向復(fù)制管道,數(shù)據(jù)僅在一個(gè)方向復(fù)制:zone1 —> zone2。
[root@ceph-node-00 ~]# radosgw-admin sync group pipe create --bucket=unidirectional --group-id=unidirectiona-1 --pipe-id=test-pipe1 --source-znotallow='zone1' --dest-znotallow='zone2'
通過sync info,我們可以檢查bucket復(fù)制的流程。可以看到,當(dāng)我們從zone1中的節(jié)點(diǎn)運(yùn)行命令時(shí),sources 字段為空,并且我們沒有從外部源接收數(shù)據(jù)。畢竟,從我們運(yùn)行命令的區(qū)域,我們正在進(jìn)行單向復(fù)制,因此我們將數(shù)據(jù)發(fā)送到目的地。我們可以看到unidirectional存儲(chǔ)桶的源是zone1,目標(biāo)是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"
….
}
當(dāng)我們?cè)趜one2中運(yùn)行相同的命令時(shí),我們會(huì)看到相同的信息,但源字段顯示從zone1接收數(shù)據(jù)。單向存儲(chǔ)桶zone2未發(fā)送任何復(fù)制數(shù)據(jù),這就是sync info命令的輸出中目標(biāo)字段為空的原因。
[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"
….
}
一旦我們的配置準(zhǔn)備就緒,我們就可以進(jìn)行一些檢查,看看一切是否都按預(yù)期工作。讓我們將三個(gè)文件放入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-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
現(xiàn)在讓我們檢查一下當(dāng)我們將一個(gè)對(duì)象放入zone2時(shí)會(huì)發(fā)生什么。我們不應(yīng)該看到文件復(fù)制到zone1 ,因?yàn)槲覀兊拇鎯?chǔ)桶的復(fù)制配置是單向的。
[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-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
2024-02-0217:57:49233 fil4
一段時(shí)間后,我們檢查了 zone1,發(fā)現(xiàn)該文件不存在,這意味著它沒有按預(yù)期從 zone2 復(fù)制。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://unidirectional
2024-02-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
圖片
在此示例中,我們將通過添加名為backupbucket新復(fù)制目標(biāo)存儲(chǔ)桶來修改之前的單向同步策略。一旦我們?cè)O(shè)置了同步策略,上傳到zone1中unidirectional存儲(chǔ)桶的每個(gè)對(duì)象都將被復(fù)制到zone2中unidirectional存儲(chǔ)桶和backupbucket中。
首先,讓我們創(chuàng)建存儲(chǔ)桶backupbucket :
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 mb s3://backupbucket
make_bucket: backupbucket
我們將向現(xiàn)有同步組策略添加一個(gè)名為backupbucket的新管道。我們?cè)谥暗膗nidirectional示例中創(chuàng)建了組同步策略。
再次,我們指定源區(qū)域和目標(biāo)區(qū)域,因此我們的同步將是單向的。主要區(qū)別在于,現(xiàn)在我們使用--dest-bucket參數(shù)指定名為backupbucket的目標(biāo)存儲(chǔ)桶。
[root@ceph-node-00 ~]# radosgw-admin sync group pipe create --bucket=unidirectional --group-id=unidirectiona-1 --pipe-id=test-pipe2 --source-znotallow='zone1' --dest-znotallow='zone2' --dest-bucket=backupbucket
再次,讓我們檢查同步信息輸出,它向我們顯示了我們已配置的復(fù)制流的表示。源字段為空,因?yàn)樵趜one1中我們沒有從任何其他源接收數(shù)據(jù)。在目的地,我們現(xiàn)在有兩個(gè)不同的pipes 。我們?cè)谇懊娴氖纠袆?chuàng)建的第一個(gè)test-pipe1 。第二個(gè)管道將backupbucket設(shè)置為zone2中的復(fù)制目標(biāo)。
[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包含三個(gè)文件:
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://unidirectional/
2024-02-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
在有四個(gè)文件的zone2中, fil4不會(huì)復(fù)制到zone1因?yàn)閺?fù)制是單向的。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls s3://unidirectional/
2024-02-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
2024-02-0217:57:49233 fil4
讓我們向zone1添加另外三個(gè)文件。我們希望將它們復(fù)制到zone2中的unidirectional存儲(chǔ)桶和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-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
2024-02-0218:03:51233 fil5
2024-02-0218:04:37233 fil6
2024-02-0218:09:08233 fil7
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 ls s3://unidirectional
2024-02-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
2024-02-0217:57:49233 fil4
2024-02-0218:03:51233 fil5
2024-02-0218:04:37233 fil6
2024-02-0218:09:08233 fil7
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 ls s3://backupbucket
2024-02-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
2024-02-0218:03:51233 fil5
2024-02-0218:04:37233 fil6
2024-02-0218:09:08233 fil7
我們將所有對(duì)象復(fù)制到所有存儲(chǔ)桶中——除了fil4 。這是滿足預(yù)期的,因?yàn)槲募焉蟼鞯絲one2 ,并且我們的復(fù)制是單向的,因此從zone2到zone1沒有同步。
如果我們查詢backupbucketsync info會(huì)輸出什么?此存儲(chǔ)桶僅在另一個(gè)存儲(chǔ)桶策略中引用,但存儲(chǔ)桶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"
},
對(duì)于這種情況,我們使用hints ,因此即使備份沒有直接參與unidirectional bucket同步策略,也會(huì)通過hint來引用。
[!CAUTION]
請(qǐng)注意,在輸出中,我們可以看到,存儲(chǔ)桶backupbucket間接找到了有關(guān)存儲(chǔ)桶unidirectional信息,而不是從其自己的策略中發(fā)現(xiàn):backupbucket本身的策略為空。
3.存儲(chǔ)桶同步策略注意事項(xiàng)
有一點(diǎn)需要注意,元數(shù)據(jù)始終會(huì)同步到其他區(qū)域,與存儲(chǔ)桶同步策略無關(guān)。因此,每個(gè)用戶和存儲(chǔ)桶,即使未配置復(fù)制,也會(huì)顯示在屬于區(qū)域組的所有區(qū)域中。
舉個(gè)例子,讓我們創(chuàng)建一個(gè)名為 newbucket的新存儲(chǔ)桶:
[root@ceph-node-00 ~]# aws --endpoint http://object.s3.zone2.dan.ceph.blue:80 s3 mb s3://newbucket
make_bucket: newbucket
我們確認(rèn)此存儲(chǔ)桶沒有配置任何復(fù)制:
[root@ceph-node-00 ~]# radosgw-admin bucket sync checkpoint --bucket newbucket
Sync is disabled for bucket newbucket
但所有元數(shù)據(jù)都會(huì)同步到輔助區(qū)域,以便存儲(chǔ)桶將出現(xiàn)在zone2中。無論如何,桶內(nèi)的數(shù)據(jù)都不會(huì)被復(fù)制。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls | grep newbucket
2024-02-0202:22:31 newbucket
另一件需要注意的事情是,在為存儲(chǔ)桶配置同步策略之前上傳的對(duì)象不會(huì)同步到其他區(qū)域,直到我們?cè)趩⒂么鎯?chǔ)桶同步后上傳對(duì)象。當(dāng)我們將新對(duì)象上傳到存儲(chǔ)桶時(shí),此示例會(huì)同步:
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://objectest1/
2024-02-0204:03:47233 file1
2024-02-0204:03:50233 file2
2024-02-0204:03:53233 file3
2024-02-0204:27:19233 file4
[root@ceph-node-00 ~]# ssh ceph-node-04 radosgw-admin bucket sync checkpoint --bucket objectest1
2024-02-02T04:17:15.596-05007fc00c51f800 1 waiting to reach incremental sync..
2024-02-02T04:17:17.599-05007fc00c51f800 1 waiting to reach incremental sync..
2024-02-02T04:17:19.601-05007fc00c51f800 1 waiting to reach incremental sync..
2024-02-02T04:17:21.603-05007fc00c51f800 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-05007fce4cf11800 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-0204:03:47233 file1
2024-02-0204:03:50233 file2
2024-02-0204:03:53233 file3
2024-02-0204:27:19233 file4
當(dāng)存儲(chǔ)桶同步策略處于allowed或forbidden狀態(tài)時(shí)創(chuàng)建、修改或刪除的對(duì)象,再次啟用該策略時(shí)將不會(huì)自動(dòng)同步。
我們需要運(yùn)行bucket sync run命令來同步這些對(duì)象并使兩個(gè)區(qū)域中的存儲(chǔ)桶保持同步。例如,我們禁用存儲(chǔ)桶objectest1的同步,并將幾個(gè)對(duì)象放入zone1中,即使我們?cè)俅螁⒂脧?fù)制,這些對(duì)象也不會(huì)復(fù)制到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-0204:03:47233 file1
2024-02-0204:03:50233 file2
2024-02-0204:03:53233 file3
2024-02-0204:27:19233 file4
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone1.dan.ceph.blue:443 s3 ls s3://objectest1/
2024-02-0204:03:47233 file1
2024-02-0204:03:50233 file2
2024-02-0204:03:53233 file3
2024-02-0204:27:19233 file4
2024-02-0204:44:45233 file5
2024-02-0204:45:38233 file6
為了使存儲(chǔ)桶恢復(fù)同步,我們從目標(biāo)區(qū)域使用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-0204:03:47233 file1
2024-02-0204:03:50233 file2
2024-02-0204:03:53233 file3
2024-02-0204:27:19233 file4
2024-02-0204:44:45233 file5
2024-02-0204:45:38233 file6
4.總 結(jié)
在本系列的第六部分中,我們繼續(xù)深入探討了多站點(diǎn)同步策略,并通過實(shí)踐示例展示了包括單源到多目標(biāo)桶的單向復(fù)制在內(nèi)的多種配置方案。