amazon-web-services - 使用手动快照将数据从一个弹性搜索索引迁移到 AWS 中不同区域的另一个索引
问题描述
我创建了两个弹性搜索域——一个在 us-east-1 中,另一个在 us-west-2 中。我在 us-east-1 域中注册了手动快照存储库并拍摄了快照,数据在 us-east-1 的 s3 存储桶中。
我应该如何进行修复?
主要问题:
我是否必须将 s3 存储桶跨区域复制到 us-west-2,以便每次在 us-east-1 中拍摄快照时,它都会自动反映到 us-west-2 存储桶?
如果是这样,我是否必须在 us-west-2 中才能在域和该 s3 存储桶上注册手动快照存储库?
还原 API 会是这样吗?curl -XPOST 'elasticsearch-domain-endpoint-us-west-2/_snapshot/repository-name/snapshot-name/_restore'
解决方案
1.- 不,正如 Val 所说,您不需要在多个区域创建 S3 存储桶。“所有存储桶在全球范围内工作” 具有多个区域的 AWS S3 存储桶
2.- 是的。您需要在两个集群中创建快照存储库。一个存储库用于创建快照到 us-east-1 中的 S3 存储桶,另一个存储库用于创建 us-west-2 中的快照主机,以便从目标集群中读取数据。
3.- 是的。此外,您需要签署对 AWS ES 的调用才能创建存储库并拍摄快照。对我来说最好的选择是使用下面描述的 Python 脚本。要恢复它是没有必要的。
请遵循以下说明: https ://medium.com/docsapp-product-and-technology/aws-elasticsearch-manual-snapshot-and-restore-on-aws-s3-7e9783cdaecb和 https://docs.aws.amazon。 com/elasticsearch-service/latest/developerguide/es-managedomains-snapshots.html
创建存储库
import boto3
import requests
from requests_aws4auth import AWS4Auth
host = 'https://localhost:9999/' # include https:// and trailing / Your elasticsearch endpoint, if you use VPC, you can create a tunnel
region = 'us-east-1' # 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)
path = '_snapshot/yourreponame' # the Elasticsearch API endpoint
url = host + path
payload = {
"type": "s3",
"settings": {
"bucket": "yourreponame_bucket",
"region": "us-east-1",
"role_arn": "arn:aws:iam::1111111111111:role/AmazonESSnapshotRole" <-- Don't forget to create the AmazonESSnapshotRole
}
}
headers = {"Content-Type": "application/json"}
r = requests.put(url, auth=awsauth, json=payload, headers=headers, verify=False)
print(r.status_code)
print(r.text)
创建快照
import boto3
import requests
from requests_aws4auth import AWS4Auth
host = 'https://localhost:9999/' # include https:// and trailing /
region = 'us-east-1' # 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)
path = '_snapshot/yourreponame/yoursnapshot_name' # the Elasticsearch API endpoint
url = host + path
payload = {
"indices": "*",
"include_global_state": "false",
"ignore_unavailable": "false"
}
headers = {"Content-Type": "application/json"}
r = requests.put(url, auth=awsauth, json=payload, headers=headers, verify=False)
print(r.status_code)
print(r.text)
恢复
必须在没有签名的情况下调用
curl -XPOST -k "https://localhost:9999/_snapshot/yourreponame/yoursnapshot_name/_restore" \
-H "Content-type: application/json" \
-d $'{
"indices": "*",
"ignore_unavailable": false,
"include_global_state": false,
"include_aliases": false
}'
强烈建议集群具有相同的版本。
推荐阅读
- android - VMWare Fusion 中的 Intel HAXM 错误 - 无法运行 Android 应用程序
- django - 如何在 Django REST 框架中显示外键数据?
- javascript - 如何在 Vue.js 中使用 async/await?
- asp.net - 我尝试了所有答案来解决这个“解析器错误消息:无法加载类型'Inventory123.WebApiApplication'”。但没有成功
- javascript - 不一致的 Javascript 元素控件
- haskell - 操纵 Haskell Monad 状态
- asp.net-core - 如何解决 ASP.NET Core 中的 Redis Multiplexer 问题
- ios - 重新启动应用程序时,为什么我的 CoreData 更新没有持续存在?
- r - 如何删除R中列联表中的一行?
- android - 运行此 AVD 需要 Intel HAXM