当我尝试从 Amazon OpenSearch Service 中的手动快照还原索引时,还原失败,并显示一条错误消息。如何解决此问题?
解决方法
Amazon OpenSearch Service 会监控 .kibana 索引,并在该索引被删除时重新创建。此行为可能会导致恢复失败,并显示以下错误消息:
{
"error": {
"root_cause": [{
"type": "snapshot_restore_exception",
"reason": "[repository-name:snapshot-name/1A2B34aZQFWQpFOYYJfxmQ] cannot restore index [.kibana] because an open index with same name already exists in the cluster. Either close or delete the existing index or restore the index under a different name by providing a rename pattern and replacement name"
}],
"type": "snapshot_restore_exception",
"reason": "[repository-name:snapshot-name/1A2B34aZQFWQpFOYYJfxmQ] cannot restore index [.kibana] because an open index with same name already exists in the cluster. Either close or delete the existing index or restore the index under a different name by providing a rename pattern and replacement name"
},
"status": 500
}
要解决此问题,请执行以下步骤:
1. 恢复索引并重命名 .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"
}
在本示例中,已将 .kibana 索引重命名为“restored_.kibana”。
2. 使用 _reindex 操作将“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"
}
}
现在,您可以从手动快照还原索引了。