如何解決 Amazon OpenSearch Service 叢集中的手動快照錯誤?

3 分的閱讀內容
0

我想要還原 Amazon OpenSearch Service 叢集的手動快照。但是,當我嘗試註冊存放庫或存取已註冊的存放庫時收到錯誤。為什麼會發生這種情況,我該如何解決這個問題?

簡短描述

若要在 OpenSearch Service 的手動快照中順利遷移資料,請執行以下步驟:

1.    選擇您要存放您的快照的 Amazon Simple Storage Service (Amazon S3) 儲存貯體。

2.    使用您的 OpenSearch Service 來源叢集註冊Amazon S3 儲存貯體。

3.    擷取 OpenSearch Service 來源叢集的快照,然後將其存放在您的 Amazon S3 儲存貯體。

4.    使用相同的 Amazon S3 儲存貯體註冊您的目的地叢集,以確保您可以檢視手動快照。

5.    在 OpenSearch Service 中的目的地叢集上還原手動快照。

否則,您可能會遇到下列其中一個問題:

  • 403 未經授權錯誤
  • repository_missing_exception
  • concurrent_snapshot_execution_exception
  • snapshot_restore_exception
  • a_w_s_security_token_service_exception
  • 「部分」快照狀態
  • Amazon S3 Glacier 儲存類別問題

解決方案

403 Unauthorized (403 未經授權) 錯誤

如果您在 OpenSearch Service 網域上已啟用精細存取控制 (FGAC),當您擷取快照時可能會收到下列錯誤:

{
    "error": {
        "root_cause": [{
            "type": "security_exception",
            "reason": "no permissions for [cluster:admin/repository/put] and User [name=arn:aws:iam::012345678912:user/username, backend_roles=[], requestedTenant=null]"
    }],
        "type": "security_exception",
        "reason": "no permissions for [cluster:admin/repository/put] and User [name=arn:aws:iam::012345678912:user/username, backend_roles=[], requestedTenant=null]"
    },
    "status": 403
}

若要解決 403 Unauthorized (403 未經授權) 錯誤,請確保每當您擷取手動快照時都指定 username:password 參數:

curl -XPUT -u 'opensearch-domain-endpoint/_snapshot/snapshot-repository-name/snapshot-name'

**注意:**您必須是進階使用者,才能為您的 OpenSearch Service 網域啟用精細存取控制。您可以使用進階使用者名稱和密碼,或將 AWS Identity Access Management (IAM) 角色設定為超級使用者。存取叢集快照時,請指定超級使用者憑證或 IAM 角色。如果您指定 IAM 角色,IAM 角色必須使用 sigv4 簽署 HTTP 請求。如需有關使用精細存取控制和 IAM 角色的詳細資訊,請參閱建立和管理 OpenSearch Service 網域

您也必須使用快照註冊快照存放庫,並且將 manage_snapshots 角色對應至 IAM 角色。manage_snapshots 角色必須具有適當許可 (IAM:PassRole) 才能承擔 IAM 角色 (TheSnapshotRole)。如需詳細資訊,請參閱手動快照先決條件

若要將 manage_snapshots 角色對應至 IAM 角色,請執行下列步驟:

1.    開啟 OpenSearch Dashboards 主控台。

2.    以主要使用者身分登入。

3.    選擇 Security (安全)。

4.    選擇 Roles (角色)。

5.    選擇 manage_snapshots 作為您的角色。

6.    選擇 Mapped users (對應的使用者)。

7.    選擇 Manage mapping (管理對應)。

8.    在 Users (使用者) 底下,新增您的使用者 ARN (例如:"arn:aws:iam::012345678912:user/username")。

9.    註冊您的手動快照存放庫

Repository_missing_exception

在擷取手動索引快照之前,您必須向 OpenSearch Service 註冊手動快照存放庫。您的 IAM 角色 (TheSnapshotRole) 也必須設定為與 Amazon S3 搭配使用。

如果您在擷取手動快照之前未註冊快照存放庫,或使用不正確的存放庫名稱,您會收到下列錯誤:

{
    "error": {
        "root_cause": [{
            "type": "repository_missing_exception",
            "reason": "[snapshot-repository-name] missing"
        }],
        "type": "repository_missing_exception",
        "reason": "[snapshot-repository-name] missing"
    },
    "status": 404
}

若要解決此錯誤,請確定您符合手動快照先決條件。此外,請確保您檢查存放庫名稱中的錯字。

Concurrent_snapshot_execution_exception

如果快照目前正在進行中,當您嘗試擷取另一個快照時會收到下列錯誤:

{
    "error": {
        "root_cause": [{
            "type": "concurrent_snapshot_execution_exception",
            "reason": "[snapshot-repository-name:snapshot-name] a snapshot is already running"
        }],
        "type": "concurrent_snapshot_execution_exception",
        "reason": "[snapshot-repository-name:snapshot-name] a snapshot is already running"
    }
}

若要檢查是否有另一個快照正在進行中,請執行下列命令:

curl -XGET 'opensearch-domain-endpoint/_snapshot/_status'

如果快照已在進行中,請等待目前的快照完成。或者,如果您懷疑快照卡住,請檢查每小時快照的歷程記錄。如需詳細資訊,請參閱為什麼無法刪除索引或升級 OpenSearch Service 叢集?

Snapshot_restore_exception

如果您嘗試將資料從內部部署叢集遷移到 OpenSearch Service 網域,則您可能會遇到下列例外狀況:

{
    "error": {
        "root_cause": [{
            "type": "snapshot_restore_exception",
            "reason": "[manual-snapshot-repo:my-manual-snapshot1/HPOcIJryTj6a6GJvyP79bw] the snapshot was created with Elasticsearch version [6.8.0] which is higher than the version of this node [6.7.0]"
        }],
        "type": "snapshot_restore_exception",
        "reason": "[manual-snapshot-repo:my-manual-snapshot1/HPOcIJryTj6a6GJvyP79bw] the snapshot was created with Elasticsearch version [6.8.0] which is higher than the version of this node [6.7.0]"
    },
    "status": 500
}

現有叢集上擷取的快照在與 OpenSearch Service 不同版本的 Elasticsearch 上執行時,會出現此錯誤訊息。如果您的叢集是在比 OpenSearch Service 還舊的 Elasticsearch 版本上執行時,請考量升級您的 Elasticsearch 版本。或者,您可以使用遠端重新索引 API 來遷移索引。

a_w_s_security_token_service_exception

如果與您的手動快照相關聯的 IAM 角色未針對 "es.amazonaws.com" 建立信任關係,您會收到下列例外狀況:

{
    "error": {
        "root_cause": [{
            "type": "repository_exception",
            "reason": "[es_01082021_repo] Could not determine repository generation from root blobs"
        }],
        "type": "repository_exception",
        "reason": "[es_01082021_repo] Could not determine repository generation from root blobs",
        "caused_by": {
            "type": "i_o_exception",
            "reason": "Exception when listing blobs by prefix [index-]",
            "caused_by": {
                "type": "a_w_s_security_token_service_exception",
                "reason": "a_w_s_security_token_service_exception: User: arn:aws:sts::332315457451:assumed-role/cp-sts-grant-role/swift-us-west-2-prod-679203657591 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::679203657591:role/ES_Backup_Role (Service: AWSSecurityTokenService; Status Code: 403; Error Code: AccessDenied; Request ID: 36d09b93-d94f-457e-8fa5-b0a50ba436c3)"
            }
        }
    },
    "status": 500
}

使用 OpenSearch Service 快照,會建立內部角色 (例如:arn:aws:sts::332315457451:assumed-role/cp-sts-grant-role/swift-us-west-2-prod-679203657591)。此內部角色承擔與手動快照相關聯的 IAM 角色,接著執行任何必要的操作。

若要解決安全性權杖例外,請務必指定與手動快照相關聯的 IAM 角色。如果您沒有與手動快照相關聯的 IAM 角色,則必須建立一個角色。如需詳細資訊,請參閱手動快照先決條件

此外,請檢查與手動快照相關聯之 IAM 角色的信任關係。角色的信任關係必須在主體陳述式中指定 OpenSearch Service,如下所示:

{
    "Version": "2012-10-17",
    "Statement": [{
        "Sid": "",
        "Effect": "Allow",
        "Principal": {
            "Service": "es.amazonaws.com"
        },
        "Action": "sts:AssumeRole"
    }]
}

部分快照狀態

快照進入「部分」狀態,原因如下:

部分快照表示無法儲存分區中的資料。您仍然可以從部分快照還原資料,但是您必須使用較早的快照來還原任何遺失的索引。若要檢查叢集是否已進入「部分」狀態,請檢查您的快照歷程記錄。如需詳細資訊,請參閱還原快照

Amazon S3 Glacier 儲存類別問題

如果您是將還原的快照存放在 Amazon S3 Glacier 儲存類別,請避免將 Amazon S3 Glacier 生命週期規則套用到儲存貯體。手動快照不支援 Amazon S3 Glacier 儲存類別。因此,如果您將 Amazon S3 Glacier 生命週期政策套用到 S3 儲存貯體,您必須將轉換的任何物件移回。

將物件移回標準 Amazon S3 儲存類別之後,您可以從這些快照還原物件。如需詳細資訊,請參閱手動快照先決條件


相關資訊

如何解決 Amazon OpenSearch Service 中的「無法恢復索引 [.kibana],因為它已開啟」錯誤?

擷取手動快照

AWS 官方
AWS 官方已更新 2 年前