如何解决 Amazon Elasticsearch Service 中的错误“无法还原索引 ,因为它已打开”?
上次更新时间:2020 年 1 月 9 日
当我尝试从 Amazon Elasticsearch Service (Amazon ES) 中的手动快照还原索引时,还原失败,并显示如下错误消息:
{"error":{"root_cause":
cannot restore index because it's
open"}],"type":"snapshot_restore_exception","reason":"
cannot restore index because it's open"},"status":500}
解决方法
在 Elasticsearch 版本 5.1 及更高版本中,Amazon ES 监控 .kibana 索引并在索引被删除时重新创建索引。此行为可能导致还原失败。要解决此问题:
1.运行类似于以下内容的命令,以还原索引并对 .kibana 索引重命名。在本示例中,.kibana 索引被重命名为“restored_.kibana”。
# restore indices.
$ curl -XPOST -H 'Content-Type: application/json' 'https://your-domain-end-point/_snapshot/your-repository-name/your-snapshot-name/_restore' -d '
{
"indices": "*",
"ignore_unavailable": true,
"include_global_state": true,
"rename_pattern": ".kibana",
"rename_replacement": "restored_.kibana"
}'
2.使用 _reindex API 操作将“restored_.kibana”重命名回“.kibana”。示例:
# reindex restored_.kibana to .kibana
$ curl -XPOST -H 'Content-Type: application/json' 'https://your-domain-end-point/_reindex' -d '
{
"source": {
"index": "restored_.kibana"
},
"dest": {
"index": ".kibana"
}
}'
现在,您可以从手动快照中还原索引。