Elasticsearch快照恢复与内部系统索引发生冲突

b5lpy0ml  于 2023-08-03  发布在  ElasticSearch
关注(0)|答案(1)|浏览(133)

我们正在尝试使用以下命令恢复以前创建的快照:

POST /_snapshot/my_backup/my_snapshot_2023.06.30/_restore

字符串
但是,该命令不断收到错误消息... index [.xxxxxx] because an open index with same name already exists in the cluster. ...。索引名称.xxxxxx表示内部系统索引。

{
  "error": {
    "root_cause": [
      {
        "type": "snapshot_restore_exception",
        "reason": "[my_backup:my_snapshot_2023.06.30/Pl0QeAojSgq1p6PYI_JdDg] cannot restore index [.ds-ilm-history-5-2023.02.17-000001] 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": "[my_backup:my_snapshot_2023.06.30/Pl0QeAojSgq1p6PYI_JdDg] cannot restore index [.ds-ilm-history-5-2023.02.17-000001] 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
}


此外,我们试图通过this post后面的命令DELETE /_all删除所有索引,但它也不起作用。错误消息为:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Wildcard expressions or all indices are not allowed"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Wildcard expressions or all indices are not allowed"
  },
  "status": 400
}


测试中的Elasticsearch示例运行在本地虚拟机上,我们有虚拟机的备份。所以,我们可以尝试任何命令,如果有必要,没有风险。

我们的问题:

  • 命令GET /_cat/indices不显示任何内部索引。那么,如何列出所有的内部系统指标呢?
  • 我们是新的备份和恢复功能,所以我们想知道是否有什么错误时,采取的快照之前。我们使用了PUT /_snapshot/my_backup/%3Cmy_snapshot_%7Bnow%2Fd%7D%3E命令,不确定是否应该包含额外的参数来忽略系统索引。
  • 是否可以删除所有索引,包括内部和外部?

我们将非常感谢任何提示和建议。

mlmc2os5

mlmc2os51#

请在下面找到我对每个问题的答案。你没有提到你正在使用哪个版本,因此下面的答案是基于最新的ElasticSearch版本。
您可以使用以下命令列出所有索引
GET _cat/indices/_all?expand_wildcards=all
如果您想恢复特定索引,则有两个选项可以恢复它。

第一个选项,删除现有的特定索引并恢复。

- You can use below command to delete index or data stream.

#Delete an index
DELETE my-index

#Delete a data stream
DELETE _data_stream/logs-my_app-default

 - You can use below command to restore the specific index.

POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
{
  "indices": "my-index,logs-my_app-default"
}

字符串

第二个选项,恢复重命名索引,重新索引到原索引

- Restore to rename index (new index) first using below command:

POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
{
  "indices": "my-index,logs-my_app-default",
  "rename_pattern": "(.+)",
  "rename_replacement": "restored-$1"
}

 - Delete the original Index and reindex data from rename index to
   original index

# Delete the original index
DELETE my-index

# Reindex the restored index to rename it
POST _reindex
{
  "source": {
    "index": "restored-my-index"
  },
  "dest": {
    "index": "my-index"
  }
}


您可以使用以下命令删除所有索引和数据斯特雷姆:

# delete all index
DELETE *?expand_wildcards=all

# delete all data stream
DELETE _data_stream/*?expand_wildcards=all


请查看this文档了解更多详细信息。
请查看此文档了解如何恢复整个群集。

相关问题