簡體   English   中英

在 Elasticsearch 中存儲庫_missing_exception 快照和還原

[英]repository_missing_exception snapshot and restore in Elasticsearch

我必須將 Windows 機器上的 Elasticsearch 索引傳輸到 Ubuntu 機器。 我決定拍攝索引的快照,然后嘗試在另一個系統上恢復它。

我成功地在 Windows 機器上對索引進行了快照。 在Windows機器中elasticsearch.yml我有path.repo: ["F:\\\\mount\\\\backups"]

所以,在mount我有:

.
└── backups
    └── old_backup
        ├── index
        ├── indices
        │   └── old_index
        │       ├── 0
        │       ├── 1
        │       ├── 2
        │       ├── 3
        │       ├── 4
        │       └── meta-snapshot_to_ubuntu.dat
        ├── meta-snapshot_to_ubuntu.dat
        └── snap-snapshot_to_ubuntu.dat

其中snapshot_to_ubuntu是我在 Windows 上制作的快照的名稱。

我把這種快照~/Documents/mount ubuntu的機器上,並開始ES 2.3.0用的一個實例path.repo: ["/home/animesh/Documents/mount/backups"]elasticsearch.yml

我在命令行上運行以下命令:

curl -XGET localhost:9200/_snapshot/old_backup/snapshot_to_ubuntu?pretty=1

並得到

{
  "error" : {
    "root_cause" : [ {
      "type" : "repository_missing_exception",
      "reason" : "[old_backup] missing"
    } ],
    "type" : "repository_missing_exception",
    "reason" : "[old_backup] missing"
  },
  "status" : 404
}

我哪里錯了?

更新

我運行了以下 curl 命令:

curl -X POST http://localhost:9200/_snapshot/old_backup/snapshot_to_ubuntu/_restore

我得到:

{
  "error": {
    "root_cause": [
      {
        "type": "repository_missing_exception",
        "reason": "[old_backup] missing"
      }
    ],
    "type": "repository_missing_exception",
    "reason": "[old_backup] missing"
  },
  "status": 404
}

我有一個類似的問題,我想與您分享我是如何解決這個問題的。 我會寫所有步驟,希望它也可以幫助其他人。

我不得不將 GCP 服務器上的 Elasticsearch 索引傳輸到我的本地機器。 我決定拍攝索引的快照,然后嘗試在我的本地機器上恢復它。

我假設您已經擁有快照

步驟是:

  1. 使用要恢復的快照在本地計算機上創建一個目錄

  2. 導航到elasticsearch.yml文件。 例如,在我的本地機器上,您可以在這里找到該文件: /usr/local/Cellar/elasticsearch/7.8.1/libexec/config/elasticsearch.yml

  3. 添加該存儲庫路徑: path.repo: [PATH_TO_BACKUP_DIR]elasticsearch.yml文件。 例如: path.repo: ["/mount/backups", "/mount/longterm_backups"]

  4. 保存、退出並重啟elasticsearch

  5. 重啟所有節點后,可以使用以下命令注冊名為my_fs_backup的共享文件系統存儲庫

  6. curl -X PUT "localhost:9200/_snapshot/my_fs_backup?pretty" -H 'Content-Type: application/json' -d' { "type": "fs", "settings": { "location": "PATH_TO_BACKUP_DIR" , // 示例:location" : "/usr/local/etc/elasticsearch/elastic-backup" "compress": true } }'

  7. 檢查您的配置: curl -X GET "localhost:9200/_snapshot/_all?pretty"

  8. 從快照恢復:

    8.1獲取所有快照: curl -X GET "localhost:9200/_snapshot/my_fs_backup/*?pretty

你會看到這個畫面: 在此處輸入圖片說明

選擇你想要的快照(如果你有多個)

使用此命令恢復:

curl -X POST "localhost:9200/_snapshot/BACKUP_NAME/SNAPSHOT_ID/_restore?pretty" -H 'Content-Type: application/json' -d'
       {
        "indices": "users, events",
        "ignore_unavailable": true,
        "include_global_state": true
       }

例如:

 curl -X POST "localhost:9200/_snapshot/my_fs_backup/elastic-snapshot-2020.09.05-lwul1zb9qaorq0k9vmd5rq/_restore?pretty" -H 'Content-Type: application/json' -d'
{
    "indices": "users, events",
    "ignore_unavailable": true,
    "include_global_state": true
 }

注意我只導入了 2 個索引usersevents

希望能幫到你😃

更多信息和擴展教程: 彈性網站jee-appy blogspot

curl -XGET localhost:9200/_snapshot/old_backup/snapshot_to_ubuntu?pretty=1

該命令創建快照。 因為您沒有在 ubuntu 端創建存儲庫,所以會出現錯誤。

你想要的是恢復所以你應該使用_restore端點:

POST /_snapshot/old_backup/snapshot_to_ubuntu/_restore

檢查: https : //www.elastic.co/guide/en/elasticsearch/reference/2.3/modules-snapshots.html#_restore

注意:此解決方案使用略有不同的存儲庫存儲,但行為預計是相同的!

我知道這是一個僵屍問題,但我目前在使用 Azure 存儲庫插件測試 ElasticSnapshots 的還原過程時偶然發現了這個問題。

我在舊的 PAAS Openstack 上創建了一個快照,並嘗試在我之前測試過 Azure 存儲庫連接的新 Azure Elastic 集群上進行恢復。 在我的情況下,我仍然得到了“存儲庫位置”:

{
  "type": "azure",
  "settings": {
    "container": "restore",
    "chunk_size": "32MB",
    "compress": true
  }
}

但是恢復總是讓我丟失存儲庫異常:

{
 "error" : {
  "root_cause" : [
   {
    "type" : "repository_missing_exception",
    "reason" : "[restore] missing"
   }
  ],
  "type" : "repository_missing_exception",
  "reason" : "[restore] missing"
 },
 "status" : 404
}

事實證明,另一個分支部署在我的測試 Azure k8s 集群上,它刪除了 Azure 存儲庫插件以及與存儲庫的連接。 即使恢復插件也無助於修復missing_repository_exception

仔細重新閱讀文檔( https://www.elastic.co/guide/en/elasticsearch/reference/7.9/snapshots-register-repository.html )給了我這個:

您可以使用刪除快照存儲庫 API 取消注冊存儲庫。 取消注冊存儲庫時,Elasticsearch 僅刪除對存儲庫存儲快照的位置的引用。 快照本身保持原樣。

所以在我的例子中解決了missing_repository_exception是做一個“有點可怕”的事情:

DELETE /_snapshot/restore

然后使用以下命令重新創建快照位置:

PUT https://localhost:9200/_snapshot/restore --data '
 {
   "type": "azure",
   "settings": {
     "container": "restore",
     "chunk_size": "32MB",
     "compress": true
   }
 }'

然后之前失敗的快照恢復命令成功了:

 POST https://localhost:9200/_snapshot/restore/snapshot_2020810/_restore
 {"accepted":true}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM