Easysearch 使用 AWS S3 進行快照備份與還原:完整指南及常見錯誤排查

Easysearch 可以使用 AWS S3 作為遠程存儲庫,進行索引的快照(Snapshot)備份和恢復。同時,Easysearch 內置了 S3 插件,無需額外安裝。以下是完整的配置和操作步驟。


1. 在 AWS S3 上創建存儲桶

  1. 登錄 AWS 控制臺,進入 S3 服務。
  2. 創建一個新存儲桶(例如 easysearch-backups)。
  3. 啟用版本控制(可選,但推薦)。
  4. 權限配置:確保 IAM 角色具有訪問 S3 的權限。
{
"Version": "2012-10-17",
"Statement": [{"Action": ["s3:ListBucket"],"Effect": "Allow","Resource": ["arn:aws:s3:::s3-bucket-name"]},{"Action": ["s3:GetObject","s3:PutObject","s3:DeleteObject"],"Effect": "Allow","Resource": ["arn:aws:s3:::s3-bucket-name/*"]}
]
}

2. 在 Console 上注冊 S3 作為快照存儲庫

使用 Console DevTools 或 API

在 Easysearch 的 DevTools 執行:

PUT _snapshot/my_s3_repository
{"type": "s3","settings": {"bucket": "easysearch-backups","base_path": ""}
}

注意

  • bucket 需要填寫你的 S3 存儲桶名稱。
  • region 需要替換成你的 AWS S3 所在區域,SDK 默認美東區。
  • 如果 Bucket 在中國區,還需添加 endpoint: https://s3.<region>.amazonaws.com.cn 參數。

3. 創建快照

一旦 my_s3_repository 注冊完成,就可以創建快照:

PUT _snapshot/my_s3_repository/my_snapshot_001
{"indices": "my_index","include_global_state": false
}

查看當前存儲的快照:

GET _snapshot/my_s3_repository/_all

image-20250309161102887

4. 從 AWS S3 還原快照

當你需要恢復索引時:

POST _snapshot/my_s3_repository/my_snapshot_001/_restore
{"indices": "my_index","rename_pattern": "my_index","rename_replacement": "restored_my_index"
}

說明:這會從 my_snapshot_001 還原 my_index,但以 restored_my_index 命名,避免與現有索引沖突。

如果要直接覆蓋原索引(確保 my_index 為空或已刪除):

POST _snapshot/my_s3_repository/my_snapshot_001/_restore
{"indices": "my_index","ignore_unavailable": true,"include_global_state": false
}

5. 可能的錯誤與解決方案

錯誤信息可能原因解決方案
repository_s3 plugin not installed沒有安裝 repository-s3 插件運行 bin/elasticsearch-plugin install repository-s3 并重啟
NoSuchBucketS3 存儲桶不存在確保 S3 存儲桶名稱正確
AccessDenied權限不足確保 S3 存儲桶策略正確,檢查 IAM 角色
index_closed_exception目標索引已關閉POST my_index/_open 再恢復
index_already_exists_exception目標索引已存在DELETE my_index 再恢復

6. 快照恢復常見錯誤排查

報錯 1:無法連接到 S3


{"error": {"root_cause": [{"type": "repository_verification_exception","reason": "[my_s3_repository] path [/] is not accessible on master node"}],"type": "repository_verification_exception","reason": "[my_s3_repository] path [/] is not accessible on master node","caused_by": {"type": "i_o_exception","reason": "Unable to upload object [//tests-sXkmh3q5ThCCIX2VJp609g/master.dat] using a single upload","caused_by": {"type": "sdk_client_exception","reason": "Failed to connect to service endpoint: ","caused_by": {"type": "socket_timeout_exception","reason": "Connect timed out"}}}},"status": 500
}
解決方案
  1. 在 keystore 中添加 AWS 憑證:
    sudo ./bin/easysearch-keystore add s3.client.default.access_key
    sudo ./bin/easysearch-keystore add s3.client.default.secret_key
    
  2. 如果運行在 EC2 上,確保實例掛載了 IAM Role。
{"error": {"root_cause": [{"type": "repository_verification_exception","reason": "[my_s3_repositor1] path  is not accessible on master node"}],"type": "repository_verification_exception","reason": "[my_s3_repositor1] path  is not accessible on master node","caused_by": {"type": "i_o_exception","reason": "Unable to upload object [tests-sUUzs-mTSZeYw1qk372DkQ/master.dat] using a single upload","caused_by": {"type": "sdk_client_exception","reason": "The requested metadata is not found at http://169.254.169.254/latest/meta-data/iam/security-credentials/"}}},"status": 500
}

報錯 2:索引已存在,無法恢復

{"error": {"root_cause": [{"type": "snapshot_restore_exception","reason": "[my_s3_repository:1/9gIDCgSySwKzQqEYvaGM_w] cannot restore index [my_index] 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_s3_repository:1/9gIDCgSySwKzQqEYvaGM_w] cannot restore index [my_index] 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. 刪除現有索引后恢復
    DELETE /my_index
    
  2. 關閉索引后恢復
    POST /my_index/_close
    
  3. 恢復為新的索引名稱
    POST _snapshot/my_s3_repository/1/_restore
    {"indices": "my_index","rename_pattern": "my_index","rename_replacement": "restored_my_index"
    }
    

報錯 3:權限錯誤

{"error": {"root_cause": [{"type": "security_exception","reason": "no permissions for [] and User [name=admin, external_roles=[admin]]"}],"type": "security_exception","reason": "no permissions for [] and User [name=admin, external_roles=[admin]]"},"status": 403
}
解決方案
  1. 確保用戶有 manage_snapshots 角色權限
  2. 排除 .security 索引或全局狀態,否則無法恢復。

在這里插入圖片描述

POST _snapshot/my_s3_repositor1/snapshot_002/_restore
{"indices": "-.security","ignore_unavailable": true,"include_global_state": false
}

📌 存儲庫(Repository)管理 API

存儲庫用于存儲快照,Elasticsearch 支持 AWS S3、GCS、本地等存儲。

1?? 查看所有已注冊的存儲庫

GET _snapshot/_all

示例返回

{"my_s3_repository": {"type": "s3","settings": {"bucket": "es-snapshots-bucket","region": "us-east-1"}}
}

2?? 查看特定存儲庫信息

GET _snapshot/my_s3_repository

3?? 創建存儲庫(AWS S3 示例)

PUT _snapshot/my_s3_repository
{"type": "s3","settings": {"bucket": "es-snapshots-bucket",}
}

4?? 刪除存儲庫

DELETE _snapshot/my_s3_repository

? 刪除存儲庫不會刪除快照,需要手動刪除快照!


📌 快照(Snapshot)管理 API

快照用于備份和恢復索引數據。

1?? 創建快照

備份特定索引

PUT _snapshot/my_s3_repository/snapshot_001
{"indices": "my_index","include_global_state": false
}

備份所有索引

PUT _snapshot/my_s3_repository/snapshot_002
{"include_global_state": true
}

2?? 查看所有快照

GET _snapshot/my_s3_repository/_all

3?? 查看特定快照信息

GET _snapshot/my_s3_repository/snapshot_001

4?? 刪除快照

DELETE _snapshot/my_s3_repository/snapshot_001

📌 快照恢復(Restore)API

恢復已備份的索引。

1?? 還原單個索引

POST _snapshot/my_s3_repository/snapshot_001/_restore
{"indices": "my_index","ignore_unavailable": true,"include_global_state": false
}

2?? 還原索引并重命名

POST _snapshot/my_s3_repository/snapshot_001/_restore
{"indices": "my_index","rename_pattern": "my_index","rename_replacement": "restored_my_index"
}

3?? 還原所有索引

POST _snapshot/my_s3_repository/snapshot_002/_restore

📌 快照狀態 API

查詢快照的執行狀態。

1?? 查看當前快照任務

GET _snapshot/_status

2?? 查看特定快照狀態

GET _snapshot/my_s3_repository/snapshot_001/_status

API用途
GET _snapshot/_all查看所有存儲庫
GET _snapshot/my_s3_repository查看特定存儲庫
PUT _snapshot/my_s3_repository創建存儲庫
DELETE _snapshot/my_s3_repository刪除存儲庫
PUT _snapshot/my_s3_repository/snapshot_001創建快照
GET _snapshot/my_s3_repository/_all查看所有快照
GET _snapshot/my_s3_repository/snapshot_001查看快照詳情
DELETE _snapshot/my_s3_repository/snapshot_001刪除快照
POST _snapshot/my_s3_repository/snapshot_001/_restore還原快照
GET _snapshot/_status查看快照狀態

🚀 通過本文,你可以高效地使用 AWS S3 進行 Easysearch 快照備份和恢復,并排查可能的錯誤,確保集群數據安全無憂!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/897655.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/897655.shtml
英文地址,請注明出處:http://en.pswp.cn/news/897655.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【系統架構設計師】性能評估

目錄 1. 說明2. 基準測試程序3. Web服務器的性能評估4. 系統監視5. 例題5.1 例題1 1. 說明 1.性能評估是為了一個目的&#xff0c;按照一定的步驟&#xff0c;選用一定的度量項目&#xff0c;通過建模和實現&#xff0c;對一個系統的性能進行各項檢測&#xff0c;對測試結果做…

動態規劃-第2篇

前言&#xff1a;在上一篇文章中&#xff0c;我們了解了動態規劃的基本概念和解決問題的基本思路。通過分解問題、存儲子問題的解&#xff0c;動態規劃為我們提供了高效的解決方案。然而&#xff0c;動態規劃并不是一成不變的&#xff0c;它有很多不同的技巧和變種&#xff0c;…

基于Redis實現限流

限流盡可能在滿足需求的情況下越簡單越好&#xff01; 1、基于Redsi的increment方法實現固定窗口限流 Redis的increment方法保證并發線程安全窗口盡可能越小越好(太大可能某一小段時間就打滿請求剩下的都拿不到令牌了)這個原理其實就是用當前時間戳然后除窗口大小 在這個窗口大…

【工具使用】IDEA 社區版如何創建 Spring Boot 項目(詳細教程)

IDEA 社區版如何創建 Spring Boot 項目&#xff08;詳細教程&#xff09; Spring Boot 以其簡潔、高效的特性&#xff0c;成為 Java 開發的主流框架之一。雖然 IntelliJ IDEA 專業版提供了Spring Boot 項目向導&#xff0c;但 社區版&#xff08;Community Edition&#xff09…

探索高性能AI識別和邊緣計算 | NVIDIA Jetson Orin Nano 8GB 開發套件的全面測評

隨著邊緣計算和人工智能技術的迅速發展&#xff0c;性能強大的嵌入式AI開發板成為開發者和企業關注的焦點。NVIDIA近期推出的Jetson Orin Nano 8GB開發套件&#xff0c;憑借其40 TOPS算力、高效的Ampere架構GPU以及出色的邊緣AI能力&#xff0c;引起了廣泛關注。本文將從配置性…

緊急救援!MySQL數據庫誤刪后的3種恢復方案

一、誤刪場景分類與恢復策略 ?常見誤操作場景?: DROP TABLE 誤刪單表(高頻事故)DELETE 誤刪數據(可通過事務回滾搶救)DROP DATABASE 刪除整個庫(需全量備份)服務器rm -rf(物理文件刪除)?恢復方案選擇矩陣?: 場景推薦方案時間窗口表結構刪除(DROP)備份恢復 + B…

開源免費日志服務ELK Syack代替syslog

一、ELK Stack 采集 syslog 日志的主要方式 通常&#xff0c;ELK Stack 使用 Logstash 或者 Filebeat 來采集 syslog 日志。 Beats 通常更輕量級&#xff0c;適合作為代理部署在各個日志源服務器上&#xff0c;而 Logstash 則功能更強大&#xff0c;可以進行更復雜的日志處理和…

單片機設計暖腳器研究

標題:單片機設計暖腳器研究 內容:1.摘要 本文聚焦于基于單片機設計暖腳器的研究。背景方面&#xff0c;在寒冷季節&#xff0c;暖腳器能有效改善腳部寒冷狀況&#xff0c;提升人們的舒適度&#xff0c;但傳統暖腳器存在功能單一、溫控不準確等問題。目的是設計一款智能、高效且…

藍橋杯省賽真題C++B組2024-握手問題

一、題目 【問題描述】 小藍組織了一場算法交流會議&#xff0c;總共有 50 人參加了本次會議。在會議上&#xff0c;大家進行了握手交流。按照慣例他們每個人都要與除自己以外的其他所有人進行一次握手(且僅有一次)。但有 7 個人&#xff0c;這 7 人彼此之間沒有進行握手(但這…

C#+AForge 實現視頻錄制

C#AForge 實現視頻錄制 ? 在C#中&#xff0c;使用AForge 庫實現視頻錄制功能是一個比較直接的過程。AForge 是一個開源的.NET框架&#xff0c;提供了許多用于處理圖像和視頻的類庫。 開發步驟 安裝AForge庫 ? 首先&#xff0c;確保你的項目中已經安裝了 AForge.Video和AFo…

PHP框架加載不上.env文件中的變量

以lumen5.5框架為例&#xff0c;根目錄中bootstrap文件夾下的app.php文件中 (new Dotenv\Dotenv(__DIR__./../))->load(); 是讀取所有.env中的文件的&#xff0c;這個是正常的&#xff0c;但是在代碼中的任何位置或者在config目錄下的databases.php里&#xff0c;代碼如…

21.Linux 線程庫的使用與封裝

在linux內核中并沒有線程的概念&#xff0c;只有輕量級進程LWP的概念&#xff0c;linux下的線程都是是由LWP進行模擬實現的。因此linux操作系統中不會提供線程的相關接口&#xff0c;只會提供輕量級線程的接口&#xff08;如vfork&#xff0c;clone等&#xff09;。但是在我們的…

Aliyun CTF 2025 web 復現

文章目錄 ezoj打卡OKoffens1veFakejump server ezoj 進來一看是算法題&#xff0c;先做了試試看,gpt寫了一個高效代碼通過了 通過后沒看見啥&#xff0c;根據頁面底部提示去/source看到源代碼&#xff0c;沒啥思路&#xff0c;直接看wp吧&#xff0c;跟算法題沒啥關系,關鍵是去…

《鴻蒙系統下AI模型訓練加速:時間成本的深度剖析與優化策略》

在當今數字化浪潮中&#xff0c;鴻蒙系統憑借其獨特的分布式架構與強大的生態潛力&#xff0c;為人工智能的發展注入了新的活力。隨著AI應用在鴻蒙系統上的日益普及&#xff0c;如何有效降低模型訓練的時間成本&#xff0c;成為了開發者與研究者們亟待攻克的關鍵課題。這不僅關…

Git使用(一)--如何在 Windows 上安裝 Git:詳細步驟指南

如果你想在 Windows 機器上安裝 Git&#xff0c;可以按照以下詳細指南進行操作。 第一步&#xff1a;下載 Git 可通過官網下載 適用于 Windows 的 Git 最新版本。 如果下載速度較慢&#xff0c;可以通過下面提供的百度網盤 鏈接下載安裝包&#xff0c; https://git-scm.com/d…

基于Prometheus+Grafana的Deepseek性能監控實戰

文章目錄 1. 為什么需要專門的大模型監控?2. 技術棧組成2.1 vLLM(推理引擎層)2.2 Prometheus(監控采集層)2.3 Grafana(數據可視化平臺)3. 監控系統架構4. 實施步驟4.1 啟動DeepSeek-R1模型4.2 部署 Prometheus4.2.1 拉取鏡像4.2.2 編寫配置文件4.2.3 啟動容器4.3 部署 G…

本地Git倉庫搭建(DevStar)與Git基本命令

本地Git倉庫搭建&#xff08;DevStar&#xff09;與Git基本命令 實驗環境搭建平臺Git基本命令的使用本地倉庫的創建代碼提交代碼合并版本發布 總結 實驗環境 搭建平臺 按照DevStar的Github倉庫要求&#xff0c;在終端中執行下列命令&#xff0c;即可成功安裝DevStar到本地部署…

stm32 藍橋杯 物聯網 獨立鍵盤的使用

在藍橋杯物聯網平臺里面&#xff0c;有5個外接設備&#xff0c;其中有一個就是6個獨立按鍵。首先&#xff0c;我們先看一下按鍵有關的電路圖。 電路圖與cubemx設定 由圖可見&#xff0c;獨立鍵盤組由兩行三列構成&#xff0c;我們通過行列來鎖定要訪問的獨立按鍵在哪。ROW1掛…

set_clock_groups

一、命令參數與工具處理邏輯 核心參數定義 參數定義工具行為工具兼容性-asynchronous完全異步時鐘組&#xff0c;無任何相位或頻率關系&#xff08;如獨立晶振、不同時鐘樹&#xff09;工具完全禁用組間路徑的時序分析&#xff0c;但需用戶自行處理跨時鐘域&#xff08;CDC&a…

工作記錄 2017-01-06

工作記錄 2017-01-06 序號 工作 相關人員 1 協助BPO進行Billing的工作。 修改CSV、EDI837的導入。 修改郵件上的問題。 更新RD服務器。 郝 修改的問題&#xff1a; 1、 In “Full Job Summary” (patient info.), sometime, the Visit->Facility is missed, then …