使用快照備份集合 - Amazon OpenSearch Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用快照備份集合

快照是 Amazon OpenSearch Serverless 集合的point-in-time備份,可提供災難復原功能。OpenSearch Serverless 會自動建立和管理集合的快照,以確保業務持續性和資料保護。每個快照都包含:

  • 索引中繼資料:索引的設定和映射

  • 叢集中繼資料:索引範本和別名

  • 索引資料:存放在索引中的所有文件和資料

主要優點

  • 無需手動設定的自動每小時備份

  • 零維護開銷

  • 無需額外儲存成本

  • 從意外資料遺失中快速復原

  • 從快照還原特定索引的能力

重要考量

  • 建立快照不是即時的,需要時間才能完成。

  • 快照建立期間的新文件或更新可能不會包含在快照中。

  • 您只能將快照還原至其原始集合,不能還原至新的集合。

  • 還原時,索引會收到與其原始版本不同的新 UUIDs。

  • 您一次只能執行一個還原操作。

  • 您無法在同一集合上同時啟動多個還原操作。在作用中還原操作期間嘗試還原索引會導致操作失敗。

  • 在還原操作期間,您對索引的請求會失敗。

所需的許可

若要使用快照,請在資料存取政策中設定下列許可。如需資料存取政策的詳細資訊,請參閱 資料存取政策與 IAM 政策比較

資料存取政策 API
aoss:DescribeSnapshot

GET /_cat/snapshots

GET /_cat/snapshots/aoss-automated/

GET _snapshot/aoss-automated/snapshot/

aoss:RestoreSnapshot POST /_snapshot/aoss-automated/snapshot/_restore
aoss:DescribeCollectionItems GET /_cat/recovery

您可以使用下列 AWS CLI 命令來設定政策:

以下是用於建立存取政策的範例 CLI 命令:

aws opensearchserverless create-access-policy \ --type data \ --name AWSExample-data-access-policy \ --region us-west-2 \ --policy '[ { "Rules": [ { "Resource": [ "collection/AWSExample-collection" ], "Permission": [ "aoss:DescribeSnapshot", "aoss:RestoreSnapshot", "aoss:DescribeCollectionItems" ], "ResourceType": "collection" } ], "Principal": [ "arn:aws:iam::AWSExample-account-ID:user/AWSExample-user" ], "Description": "Data policy to support snapshot operations." } ]'

使用快照

根據預設,當您建立新的集合時,OpenSearch Serverless 會每小時自動建立快照。您不需要執行任何操作。每個快照都包含集合中的所有索引。OpenSearch Serverless 建立快照後,您可以使用下列命令列出快照並檢視快照的詳細資訊。

列出快照

使用下列命令列出集合中的所有快照:

GET /_cat/snapshots/aoss-automated/

OpenSearch Serverless 會傳回類似以下的回應:

id status start_epoch start_time end_epoch end_time duration indices successful_shards failed_shards total_shards snapshot-AWSExampleSnapshotID1 SUCCESS 1737964331 07:52:11 1737964382 07:53:02 50.4s 1 snapshot-AWSExampleSnapshotID2 SUCCESS 1737967931 08:52:11 1737967979 08:52:59 47.7s 2 snapshot-AWSExampleSnapshotID3 SUCCESS 1737971531 09:52:11 1737971581 09:53:01 49.1s 3 snapshot-AWSExampleSnapshotID4 IN_PROGRESS 1737975131 10:52:11 - - 4.8d 3

取得快照

擷取有關快照的資訊。

GET _snapshot/aoss-automated/snapshot/

範例請求

GET _snapshot/aoss-automated/snapshot-AWSExampleSnapshotID1/

回應範例

{ "snapshots": [ { "snapshot": "snapshot-AWSExampleSnapshotID1-5e01-4423-9833Example", "uuid": "AWSExample-5e01-4423-9833-9e9eb757Example", "version_id": 136327827, "version": "2.11.0", "remote_store_index_shallow_copy": true, "indices": [ "AWSExample-index-0117" ], "data_streams": [], "include_global_state": true, "metadata": {}, "state": "SUCCESS", "start_time": "2025-01-27T09:52:11.953Z", "start_time_in_millis": 1737971531953, "end_time": "2025-01-27T09:53:01.062Z", "end_time_in_millis": 1737971581062, "duration_in_millis": 49109, "failures": [], "shards": { "total": 0, "failed": 0, "successful": 0 } } ] }

了解快照回應欄位

id

快照操作的唯一識別符。

status

快照操作的目前狀態。可能的值包括:

  • SUCCESS

  • IN_PROGRESS

持續時間

完成快照操作所需的時間。

索引

快照中包含的索引數目。

從快照還原

從快照還原可讓您從先前建立的備份復原資料。此程序對於 OpenSearch Serverless 中的災難復原和資料管理至關重要。

重要考量

  1. 還原的索引將具有與其原始版本不同的 UUIDs。

  2. 快照只能還原至其原始集合。不支援跨集合還原。

  3. 還原操作可能會影響叢集效能。請妥善規劃。

從快照還原備份的索引
  1. 執行下列命令來識別適當的快照。

    GET /_snapshot/aoss-automated/_all

    如需較小的快照清單,請執行下列命令。

    GET /_cat/snapshots/aoss-automated/
  2. 執行下列命令,在還原之前驗證快照的詳細資訊。

    GET _snapshot/aoss-automated/snapshot-AWSExampleSnapshotID1/
  3. 執行下列命令,從特定快照還原 。

    POST /_snapshot/aoss-automated/snapshot-ID/_restore

    您可以透過包含請求內文來自訂還原操作。範例如下。

    POST /_snapshot/aoss-automated/snapshot-AWSExampleSnapshotID1-5e01-4423-9833Example/_restore { "indices": "opensearch-dashboards*,my-index*", "ignore_unavailable": true, "include_global_state": false, "include_aliases": false, "rename_pattern": "opensearch-dashboards(.+)", "rename_replacement": "restored-opensearch-dashboards$1" }
  4. 執行下列命令以檢視還原進度。

    GET /_cat/recovery
注意

使用包含請求內文的命令還原快照時,您可以使用下列參數來控制還原行為:

索引

指定要還原的索引。此參數支援萬用字元模式。

ignore_unavailable

即使快照中的索引遺失,也允許還原操作繼續。

include_global_state

決定是否還原叢集狀態。

include_aliases

控制是否還原相關聯的別名。

rename_pattern 和 rename_replacement

可讓您在還原操作期間重新命名索引。