从不同的 S3 区域恢复 Elasticsearch 快照



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

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

在存储桶之间添加了 S3 存储桶复制,但当我尝试在eu-west-2AWS 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域快照到 S3ARN一样,因为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 区域的正确方法是什么?

任何建议都非常感谢。

从 eu-west-1 移动到 us-west-2 时,我收到了关于The bucket is in this region: eu-west-1. Please use this region to retry the request的类似但不相同的错误消息。

根据 Amazon 的文档(在"将数据迁移到其他域"下(,您需要指定终端节点而不是区域:

如果遇到此错误,请尝试在 PUT 语句中将"区域":"us-east-2"替换为"终结点":"s3.amazonaws.com",然后重试请求。

最新更新