Ceph 對象存儲多站點復制:將配置其他多站點同步策略
1.目標
在今天的博客第六部分中,我們將配置其他多站點同步策略,包括從一個源到多個目標存儲桶的單向復制。
2.單向桶同步
在上一篇文章中,我們探討了具有雙向配置的存儲桶同步策略。現在,讓我們通過一個示例來了解如何啟用兩個存儲桶之間的單向同步。在示例中,我們目前將區域組同步策略設置為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 。這樣,我們就為bucket unidirectional創建了一個單向復制管道,數據僅在一個方向復制: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復制的流程。可以看到,當我們從zone1中的節點運行命令時,sources 字段為空,并且我們沒有從外部源接收數據。畢竟,從我們運行命令的區域,我們正在進行單向復制,因此我們將數據發送到目的地。我們可以看到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中運行相同的命令時,我們會看到相同的信息,但源字段顯示從zone1接收數據。單向存儲桶zone2未發送任何復制數據,這就是sync info命令的輸出中目標字段為空的原因。
[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"
….
}
一旦我們的配置準備就緒,我們就可以進行一些檢查,看看一切是否都按預期工作。讓我們將三個文件放入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
現在讓我們檢查一下當我們將一個對象放入zone2時會發生什么。我們不應該看到文件復制到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-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
2024-02-0217:57:49233 fil4
一段時間后,我們檢查了 zone1,發現該文件不存在,這意味著它沒有按預期從 zone2 復制。
[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新復制目標存儲桶來修改之前的單向同步策略。一旦我們設置了同步策略,上傳到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-znotallow='zone1' --dest-znotallow='zone2' --dest-bucket=backupbucket
再次,讓我們檢查同步信息輸出,它向我們顯示了我們已配置的復制流的表示。源字段為空,因為在zone1中我們沒有從任何其他源接收數據。在目的地,我們現在有兩個不同的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-0217:56:09233 fil1
2024-02-0217:56:10233 fil2
2024-02-0217:56:11233 fil3
在有四個文件的zone2中, fil4不會復制到zone1因為復制是單向的。
[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添加另外三個文件。我們希望將它們復制到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-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
我們將所有對象復制到所有存儲桶中——除了fil4 。這是滿足預期的,因為文件已上傳到zone2 ,并且我們的復制是單向的,因此從zone2到zone1沒有同步。
如果我們查詢backupbucketsync 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 bucket同步策略,也會通過hint來引用。
[!CAUTION]
請注意,在輸出中,我們可以看到,存儲桶backupbucket間接找到了有關存儲桶unidirectional信息,而不是從其自己的策略中發現:backupbucket本身的策略為空。
3.存儲桶同步策略注意事項
有一點需要注意,元數據始終會同步到其他區域,與存儲桶同步策略無關。因此,每個用戶和存儲桶,即使未配置復制,也會顯示在屬于區域組的所有區域中。
舉個例子,讓我們創建一個名為 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中。無論如何,桶內的數據都不會被復制。
[root@ceph-node-00 ~]# aws --endpoint https://object.s3.zone2.dan.ceph.blue:443 s3 ls | grep newbucket
2024-02-0202:22:31 newbucket
另一件需要注意的事情是,在為存儲桶配置同步策略之前上傳的對象不會同步到其他區域,直到我們在啟用存儲桶同步后上傳對象。當我們將新對象上傳到存儲桶時,此示例會同步:
[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
當存儲桶同步策略處于allowed或forbidden狀態時創建、修改或刪除的對象,再次啟用該策略時將不會自動同步。
我們需要運行bucket sync run命令來同步這些對象并使兩個區域中的存儲桶保持同步。例如,我們禁用存儲桶objectest1的同步,并將幾個對象放入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-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
為了使存儲桶恢復同步,我們從目標區域使用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.總 結
在本系列的第六部分中,我們繼續深入探討了多站點同步策略,并通過實踐示例展示了包括單源到多目標桶的單向復制在內的多種配置方案。