Ceph 對象存儲多站點復制:從歸檔區域恢復數據
功能概述
讓我們從歸檔區域恢復流程的可視化表示開始。了解流程后,我們將通過一個實操示例來逐步演示。
下圖展示了當用戶向生產區域上傳(PUT)對象時,歸檔區域的行為:
- 第一次上傳:當用戶首次將 object1 上傳到生產區域時,該對象會作為當前版本復制到歸檔區域。
- 第二次上傳:當用戶第二次上傳并更新 object1 時,修改后的對象會復制到歸檔區域。此時,修改后的對象成為當前版本,而舊的(初始的、原始的)對象仍然保留在歸檔區域中,這得益于 S3 版本控制功能。
- 第三次上傳:如果用戶第三次上傳并更新 object1,將重復步驟 2 的過程,歸檔區域中將保存該對象的三個版本。
通過這種方式,歸檔區域不僅保留了對象的最新版本,還保留了歷史版本,為數據恢復提供了更多可能性。
圖片
繼續上面的示例,讓我們看看如何從邏輯故障中恢復數據。
- 誤刪除操作:在應用程序 X 的部署過程中,用戶誤操作刪除了生產區域中的 object1。然而,該對象并未從歸檔區域中刪除。
- 應用程序故障:當生產應用程序 X 嘗試訪問 object1 時,操作失敗。應用程序因此宕機,引發了緊急情況。
- 問題排查與請求:應用程序團隊對問題進行了根本原因分析(RCA),并迅速聯系存儲團隊,指定需要恢復的對象及其版本(日期/時間)。為了加快處理速度,可能還會承諾一些素食布朗尼作為感謝。
- 數據恢復:存儲團隊從歸檔區域復制 object1 的最新版本到生產集群中。
通過這種方式,歸檔區域為應對邏輯故障提供了可靠的數據恢復機制,確保關鍵數據不會因誤操作而永久丟失。
圖片
從歸檔區WorKflow 中恢復對象中的實踐操作
準備客戶端環境
我們將使用rclone CLI 工具進行測試。首先,我們為測試創建一個特定用戶,因此在zone1集群中,我們運行:
# radosgw-admin user create --uid=archuser --display-name="S3 user to test the archive zone" --access-key=archuser --secret-key=archuser
{
"user_id": "archuser",
"display_name": "S3 user to test the archive zone",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"subusers": [],
"keys": [
{
"user": "archuser",
"access_key": "archuser",
"secret_key": "archuser"
}
],
"swift_keys": [],
"caps": [],
"op_mask": "read, write, delete",
"default_placement": "",
"default_storage_class": "",
"placement_tags": [],
"bucket_quota": {
現在我們使用該用戶配置 AWS 客戶端:
# aws configure
AWS Access Key ID [None]: archuser
AWS Secret Access Key [None]: archuser
Default region name [None]: multizg
Default output format [None]: text
我們還將創建幾個別名,以簡化我們的命令。
zone 和 archive 區域的別名:
# alias s3apiarchive='aws --endpoint=https://object.s3.archive.dan.ceph.blue:443 s3api'
# alias s3apizone1='aws --endpoint=https://object.s3.zone1.dan.ceph.blue:443 s3api'
我們希望使用rclone ,所以讓我們下載并安裝對應的rclone軟件包:
# yum install https://downloads.rclone.org/v1.62.0/rclone-v1.62.0-linux-amd64.rpm -y
接下來,我們使用生產區域端點和歸檔區域端點配置rclone客戶端。這樣,如果需要,我們可以使用rclone從歸檔區域恢復數據:
cat <<EOF >rclone.conf
[zone1]
type = s3
provider = Other
access_key_id = archuser
secret_access_key = archuser
endpoint = https://object.s3.zone1.dan.ceph.blue:443
location_constraint = multizg
acl = bucket-owner-full-control
[archive]
type = s3
provider = Ceph
access_key_id = archuser
secret_access_key = archuser
endpoint = https://object.s3.archive.dan.ceph.blue:443
location_constraint = multizg
acl = bucket-owner-full-control
EOF
接下來,我們創建一些測試文件并捕獲它們的 MD5 校驗和,以便稍后進行比較:
# echo "This is file 1" > /tmp/test-file-1
# echo "This is file 2" > /tmp/test-file-2
# echo "This is file 3" > /tmp/test-file-3
# md5sum /tmp/test-file-1
88c16a56754e0f17a93d269ae74dde9b /tmp/test-file-1
# md5sum /tmp/test-file-2
db06069ef1c9f40986ffa06db4fe8fd7 /tmp/test-file-2
# md5sum /tmp/test-file-3
95227e10e2c33771e1c1379b17330c86 /tmp/test-file-3
歸檔區測試
我們的客戶端已準備就緒,現在來檢查歸檔區。
創建一個新的存儲桶,并驗證該存儲桶是否已在所有 RGW 區域中創建:
# s3apizone1 create-bucket --bucket my-bucket
# s3apizone1 list-buckets
BUCKETS 2023-03-15T12:03:54.315000+00:00 my-bucket
OWNER S3 user to test the archive zone archuser
# s3apiarchive list-buckets
BUCKETS 2023-03-15T12:03:54.315000+00:00 my-bucket
OWNER S3 user to test the archive zone archuser
驗證是否尚未配置對象版本控制,因為該功能是延遲執行的
# s3apizone1 get-bucket-versioning --bucket my-bucket
# s3apiarchive get-bucket-versioning --bucket my-bucket
將新對象上傳到我們的存儲桶my-bucket 。
# rclone copy /tmp/test-file-1 zone1:my-bucket
驗證歸檔區是否已啟用 S3 版本管理,但 zone1未啟用:
# s3apiarchive get-bucket-versioning --bucket my-bucket
{
"Status": "Enabled",
"MFADelete": "Disabled"
}
# s3apizone1 get-bucket-versioning --bucket my-bucket
驗證主備區中的對象版本 ID 是否為空,但歸檔區中的對象版本 ID 不為空:
# s3apizone1 list-object-versions --bucket my-bucket
{
"Versions": [
{
"ETag": "\"88c16a56754e0f17a93d269ae74dde9b\"",
"Size": 15,
"StorageClass": "STANDARD",
"Key": "test-file-1",
"VersionId": "null",
"IsLatest": true,
"LastModified": "2023-03-15T12:07:12.914000+00:00",
"Owner": {
"DisplayName": "S3 user to test the archive zone",
"ID": "archuser"
}
}
]
}
# s3apiarchive list-object-versions --bucket my-bucket
{
"Versions": [
{
"ETag": "\"88c16a56754e0f17a93d269ae74dde9b\"",
"Size": 15,
"StorageClass": "STANDARD",
"Key": "test-file-1",
"VersionId": "6DRlC7fKtpmkvHA9zknhFA87RjyilTV",
"IsLatest": true,
"LastModified": "2023-03-15T12:07:12.914000+00:00",
"Owner": {
"DisplayName": "S3 user to test the archive zone",
"ID": "archuser"
}
}
]
}
修改主區域中的對象并驗證是否在 RGW 歸檔區域中創建了新版本:
# rclone copyto /tmp/test-file-2 zone1:my-bucket/test-file-1
# rclone ls zone1:my-bucket
15 test-file-1
驗證 RGW 歸檔區域中已創建新版本:
# s3apiarchive list-object-versions --bucket my-bucket
{
"Versions": [
{
"ETag": "\"db06069ef1c9f40986ffa06db4fe8fd7\"",
"Size": 15,
"StorageClass": "STANDARD",
"Key": "test-file-1",
"VersionId": "mXoINEnZsSCDNaWwCDELVysUbnMqNqx",
"IsLatest": true,
"LastModified": "2023-03-15T12:13:27.057000+00:00",
"Owner": {
"DisplayName": "S3 user to test the archive zone",
"ID": "archuser"
}
},
{
"ETag": "\"88c16a56754e0f17a93d269ae74dde9b\"",
"Size": 15,
"StorageClass": "STANDARD",
"Key": "test-file-1",
"VersionId": "6DRlC7fKtpmkvHA9zknhFA87RjyilTV",
"IsLatest": false,
"LastModified": "2023-03-15T12:07:12.914000+00:00",
"Owner": {
"DisplayName": "S3 user to test the archive zone",
"ID": "archuser"
}
}
]
}
我們可以檢查 ETag:它將與對象的 MD5sum 匹配。僅當未配置分段上傳和對象加密時才會出現這種情況。
# md5sum /tmp/test-file-2
db06069ef1c9f40986ffa06db4fe8fd7 /tmp/test-file-2
# md5sum /tmp/test-file-1
88c16a56754e0f17a93d269ae74dde9b /tmp/test-file-1
從 Rgw 歸檔區恢復 S3 對象文件
讓我們上傳該對象的另一個版本
# rclone copyto /tmp/test-file-3 zone1:my-bucket/test-file-1
在主區域中,我們只有一個版本,即對象的當前版本:
# rclone --s3-versions lsl zone1:my-bucket
15 2023-03-15 07:59:10.779573336 test-file-1
但在歸檔區,我們提供了所有三個版本:
# rclone --s3-versions lsl archive:my-bucket
15 2023-03-15 07:59:10.779573336 test-file-1
15 2023-03-15 07:59:03.782438991 test-file-1-v2023-03-15-121327-057
15 2023-03-15 07:58:58.135330567 test-file-1-v2023-03-15-120712-914
現在讓我們從zone1的my-bucket中刪除test-file1 ,然后從歸檔區域恢復該對象:
# rclone delete zone1:my-bucket/test-file-1
# rclone --s3-versions lsl zone1:my-bucket
# rclone --s3-versions lsl archive:my-bucket
15 2023-03-15 07:59:10.779573336 test-file-1
15 2023-03-15 07:59:03.782438991 test-file-1-v2023-03-15-121327-057
15 2023-03-15 07:58:58.135330567 test-file-1-v2023-03-15-120712-914
該對象已從zone1中刪除,但所有版本在歸檔區域中仍然可用。如果我們恢復最新版本test-file-1它應該與我們的test-file-3的 MD5 校驗和匹配:
# rclone copyto archive:my-bucket/test-file-1 zone1:my-bucket/test-file-1
# rclone copyto zone1:my-bucket/test-file-1 /tmp/recovered-file1
# md5sum /tmp/recovered-file1
95227e10e2c33771e1c1379b17330c86 /tmp/recovered-file1
# md5sum /tmp/test-file-3
95227e10e2c33771e1c1379b17330c86 /tmp/test-file-3
現在讓我們探討一下我們想要恢復具有特定時間戳的版本的對象的情況,例如2023-03-15-121327-057 。
# rclone --s3-versions copyto archive:my-bucket/test-file-1-v2023-03-15-121327-057 zone1:my-bucket/test-file-1
# rclone copyto zone1:my-bucket/test-file-1 /tmp/recovered-file1
# md5sum /tmp/recovered-file1
db06069ef1c9f40986ffa06db4fe8fd7 /tmp/recovered-file1
# md5sum /tmp/test-file-2
db06069ef1c9f40986ffa06db4fe8fd7 /tmp/test-file-2
至此,我們完成了關于歸檔區域的實操示例,并通過 `rclone` 工具無縫恢復了數據。