如何解决我的 OpenSearch Service 集群中的手动快照错误?

4 分钟阅读
0

我尝试恢复我的 Amazon OpenSearch Service 集群的手动快照,但在尝试注册或访问存储库时出错。

简短描述

要从 OpenSearch Service 中的手动快照迁移数据,请完成以下步骤:

1.    选择要存储快照的 Amazon Simple Storage Service(Amazon S3)存储桶。

2.    将 Amazon S3 桶注册到您的 OpenSearch Service 源集群。

3.    拍摄 OpenSearch Service 源集群的快照,然后将其存储在您的 Amazon S3 桶中。

4.    使用相同的 Amazon S3 桶注册您的目标集群,以确保您可以查看手动快照。

5.    在 OpenSearch Service 中恢复目标集群上的手动快照。

否则,您可能会遇到以下错误之一:

  • 403 Unauthorized(403 未授权)错误
  • illegal_state_exception
  • repository_missing_exception
  • concurrent_snapshot_execution_exception
  • snapshot_restore_exception
  • a_w_s_security_token_service_exception
  • “PARTIAL”快照状态
  • Amazon Simple Storage Service Glacier(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(AWS IAM)角色设置为超级用户。当您访问集群快照时,请指定您的超级用户凭证或 IAM 角色。如果您指定 IAM 角色,则 IAM 角色必须使用 sigv4 来签署 HTTP 请求。有关使用精细访问控制和 IAM 角色的详细信息,请参阅创建和管理 OpenSearch Service 域

您还必须使用快照注册快照存储库,并将 manage_snapshots 角色映射到 IAM 角色。manage_snapshots 角色必须具有有效权限(IAM:PassRole)才能代入 IAM 角色(TheSnapshotRole)。有关详细信息,请参阅前提条件

要将 manage_snapshots 角色映射到 IAM 角色,请完成以下步骤:

1.    以主用户身份打开 OpenSearch Service 控制台

2.    选择 Security(安全)。

3.    选择 Roles(角色)。

4.    选择 manage_snapshots 作为您的角色。

5.    选择 Mapped users(已映射的用户)。

6.    选择 Manage mapping(管理映射)。

7.    在 Users(用户)下,添加您的用户 ARN(例如:“arn:aws:iam::012345678912:user/username”)。

8.    注册您的手动快照存储库

illegal_state_exception

当您使用多个域的 Amazon S3 桶手动拍摄快照时,会出现以下错误:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_state_exception",
        "reason": "Can't get text on a FIELD_NAME at 1:1838"
      }
    ],
    "type": "illegal_state_exception",
    "reason": "Can't get text on a FIELD_NAME at 1:1838"
  },
  "status": 500
}

要解决此问题,请创建新的 Amazon S3 桶并拍摄手动快照,或者清除现有桶中的所有数据。

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
}

当您在现有集群上拍摄的快照在不同版本的 Elasticsearch(与 OpenSearch Service 相比)上运行时,就会出现此错误消息。如果您的集群运行的 Elasticsearch 版本早于 OpenSearch Service,请升级您的 Elasticsearch 版本。或者,您可以使用远程重新索引 API 来迁移您的索引。

如果域的 FGAC 已激活,并且您尝试从快照中恢复所有索引,则可能会出现下面这样的 403 错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "no permissions for [] and User [name=RahulSarkar, backend_roles=[], requestedTenant=]"
      }
    ],
    "type" : "security_exception",
    "reason" : "no permissions for [] and User [name=RahulSarkar, backend_roles=[], requestedTenant=]"
  },
  "status" : 403
}

要解决此错误,请排除类似于下面这样的安全指数:

curl -XPOST 'username:password' "https://opensearch-domain-endpoint/_snapshot/snapshot-repository/snapshot-id/_restore" -H 'Content-Type: application/json' -d'
{
  "indices": "-.opensearch*,-.opendistro*,-.kibana*"
}'

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 角色的信任关系。角色的信任关系必须像下面这样在 Principal 语句中指定 OpenSearch Service:

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

PARTIAL(部分)快照状态

快照可能会因为以下原因进入“PARTIAL”(部分)状态:

部分快照表明无法存储分片中的数据。您仍然可以还原部分快照中的数据,但必须使用较早的快照来恢复任何丢失的索引。要检查您的集群是否已进入“PARTIAL”(部分)状态,请查看您的快照历史记录。有关详细信息,请参阅恢复快照

Amazon S3 Glacier 存储类问题

如果您将还原的快照存储在某个 S3 Glacier 存储类中,请勿将 Amazon S3 Glacier Lifecycle 应用于该桶。手动快照不支持 S3 Glacier 存储类。因此,如果您将 Amazon S3 Glacier Lifecycle 策略应用于 S3 桶,则必须移回所有转移过来的对象。

将对象移回标准的 Amazon S3 存储类后,即可从这些快照中恢复对象。有关详细信息,请参阅先决条件

相关信息

如何解决 Amazon OpenSearch Service 中的“cannot restore index [.kibana]”(无法恢复索引 [.kibana])错误?

拍摄手动快照

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