amazon-web-services - 从不同的 s3 区域恢复 elasticsearch 快照

标签 amazon-web-services elasticsearch amazon-s3 amazon-elasticsearch

我在 eu-west-1 区域中有一个 AWS ElasticSearch 域,并已将 快照 拍摄到也在同一区域中的 S3 存储桶子文件夹。

我还在另一个 aws 区域部署了第二个 AWS ElasticSearch 域 - eu-west-2

在存储桶之间添加了一个 S3 存储桶复制,但是当我尝试在 eu-west-2 AWS ES 域上注册存储库时,出现以下错误:

500
{"error":{"root_cause":[{"type":"blob_store_exception","reason":"Failed to check if blob [master.dat] exists"}],"type":"blob_store_exception","reason":"Failed to check if blob [master.dat] exists","caused_by":{"type":"amazon_s3_exception","reason":"Forbidden (Service: Amazon S3; Status Code: 403; Error Code: 403 Forbidden; Request ID: 14F0571DFF522922; S3 Extended Request ID: U1OnlKPOkfCNFzoV9HC5WBHJ+kfhAZDMOG0j0DzY5+jwaRFJvHkyzBacilA4FdIqDHDYWPCrywU=)"}},"status":500}

这是我用来在新集群上注册存储库的代码(取自 https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-managedomains-snapshots.html#es-managedomains-snapshot-restore ):

import boto3
import requests
from requests_aws4auth import AWS4Auth

host = 'https://search-**es-elk-prod**.eu-west-2.es.amazonaws.com/' # include https:// and trailing /
region = 'eu-west-2' # e.g. us-west-1
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)

# Register repository

path = '_snapshot/es-elk-prod' # the Elasticsearch API endpoint
url = host + path

payload = {
  "type": "s3",
  "settings": {
    "bucket": "es-prod-eu-west-2",
    "region": "eu-west-2",
    "role_arn": "arn:aws:iam::1234567:role/EsProd-***-snapshotS3role-***"
  }
}

headers = {"Content-Type": "application/json"}

r = requests.put(url, auth=awsauth, json=payload, headers=headers)

print(r.status_code)
print(r.text)

从日志中,我得到:

curl -X GET  'https://search-**es-elk-prod**.eu-west-2.es.amazonaws.com/_snapshot/es-mw-elk-prod/_all?pretty'
{
  "error" : {
    "root_cause" : [
      {
        "type" : "amazon_s3_exception",
        "reason" : "Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 72A59132E2830D81; S3 Extended Request ID: o0XalToNp19HDJKSOVxmna71hx3LkwoSFEobm3HQGH1HEzxOrAtYHg+asnKxJ03iGSDDhUz5GUI=)"
      }
    ],
    "type" : "amazon_s3_exception",
    "reason" : "Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 72A59132E2830D81; S3 Extended Request ID: o0XalToNp19HDJKSOVxmna71hx3LkwoSFEobm3HQGH1HEzxOrAtYHg+asnKxJ03iGSDDhUz5GUI=)"
  },
  "status" : 500
}

ARN 能够访问 S3 存储桶,因为它是我用来快照 eu-west-2 域的同一个 ARN S3 作为 eu-west-1 快照存储在 S3 存储桶的一个子文件夹中,我添加了一个代码路径,这样:

payload = {
  "type": "s3",
  "settings": {
    "bucket": "es-prod-eu-west-2",
    "path": "es-elk-prod",
    "region": "eu-west-2",
    "role_arn": "arn:aws:iam::1234567:role/EsProd-***-snapshotS3role-***"
  }
}

但这也不起作用。

将在一个 aws 区域中创建的快照恢复到另一个 aws 区域的正确方法是什么?

非常感谢任何建议。

最佳答案

我有关于 The bucket is in this region: eu-west-1 的类似但不相同的错误消息。从 eu-west-1 移动到 us-west-2 时,请使用此区域重试请求

根据 Amazon's documentation (在“将数据迁移到不同的域”下)您需要指定端点而不是区域:

If you encounter this error, try replacing "region": "us-east-2" with "endpoint": "s3.amazonaws.com" in the PUT statement and retry the request.

关于amazon-web-services - 从不同的 s3 区域恢复 elasticsearch 快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59622790/

相关文章:

angular - 将通用的 Angular 2+ 应用程序放在 AWS Lambda 上是明智的选择吗?

amazon-web-services - 我们如何为我们的 AWS 应用程序提供对客户资源的访问,而无需他们的 key ?

time - Elasticsearch-在线用户数

elasticsearch - 将NEST API与ElasticSearch结合使用时的排序选项

security - 备份至云端

java - 在 Windows Server AMI 上自动安装 Java 8

amazon-web-services - 由于安全组不同,无法创建 aurora RDS 数据库集群

elasticsearch - Elasticsearch 的 auto_generate_phrase_queries 有什么作用?

python-3.x - AWS UNLOAD 无效凭证子句

amazon-web-services - 简化多个 AWS S3 策略