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.rhkb.cn/news/32986.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Nginx + Keepalived 高可用集群

一、NginxKeepalived 原理 1.1.Nginx 负载均衡机制 Nginx 是一款轻量级且高性能的 Web 服务器和反向代理服务器&#xff0c;在负载均衡方面有着卓越的表现。其具备强大的七层流量管理能力&#xff0c;能够基于 URL、Cookie、HTTP 头信息等对请求进行精准路由。例如&#xff0…

面试提问(1)

面试提问 1.你能说一说C/C之间的区别吗&#xff1f;2.你能将一些你对构造函数和析构函数的认识吗&#xff1f;3.讲一下继承和多态4.你了解TCP/IP四层网络模型吗&#xff1f;5.你了解三次握手和四次挥手吗&#xff1f;6.讲一下进程和线程&#xff1f;7.你对二叉树的了解有哪些&a…

Adobe Genuine Service Alert 一直弹窗,老是一直弹窗【解决方法】

在使用Adobe系列软件时&#xff0c;若没有正版授权&#xff0c;则会出现弹窗&#xff0c;该弹窗是由Adobe Genuine Service软件弹出的&#xff0c;且该弹窗无法关闭&#xff0c;下文介绍如何永久关闭该弹窗。 方法一&#xff1a; 首先在任务栏鼠标右键打开任务管理器&#xff…

防汛应急包,快速响应,守护安全

根据中国水利部统计&#xff0c;自1949年以来&#xff0c;我国几乎每年都面临洪水威胁&#xff0c;其中20世纪90年代后洪涝灾害频率显著增加&#xff0c;仅1990-2009年间就发生超4000起较大灾害&#xff0c;直接经济损失近3万亿元&#xff0c;受灾人口达20亿人次。在2020年长江…

一文了解JVM的垃圾回收

Java堆内存结构 java堆内存是垃圾回收器管理的主要区域&#xff0c;也被称为GC堆。 为了方便垃圾回收&#xff0c;堆内存被分为新生代、老年代和永久代。 新创建的对象的内存会在新生代中分配&#xff0c;达到一定存活时长后会移入老年代&#xff0c;而永久代存储的是类的元数…

【人工智能 | 大数据】基于人工智能的大数据分析方法

【作者主页】Francek Chen 【专栏介绍】 ⌈ ⌈ ⌈智能大数据分析 ⌋ ⌋ ⌋ 智能大数据分析是指利用先进的技术和算法对大规模数据进行深入分析和挖掘&#xff0c;以提取有价值的信息和洞察。它结合了大数据技术、人工智能&#xff08;AI&#xff09;、机器学习&#xff08;ML&a…

【C语言】编译和链接详解

hi&#xff0c;各位&#xff0c;让我们开启今日份博客~ 小编个人主页点这里~ 目录 一、翻译环境和运行环境1、翻译环境1.1预处理&#xff08;预编译&#xff09;1.2编译1.2.1词法分析1.2.2语法分析1.2.3语义分析 1.3汇编1.4链接 2.运行环境 一、翻译环境和运行环境 在ANSI C…

在Simulink中将Excel数据导入可变负载模块的方法介绍

文章目录 数据准备与格式要求Excel数据格式MATLAB预处理数据导入方法使用From Spreadsheet模块(直接导入Excel)通过MATLAB工作区中转(From Workspace模块)使用1-D Lookup Table模块(非线性负载映射)Signal Builder模块(变载工况导入)可变负载模块配置注意事项与调试在S…

Java 大视界 -- Java 大数据在智慧文旅虚拟导游与个性化推荐中的应用(130)

&#x1f496;亲爱的朋友们&#xff0c;热烈欢迎来到 青云交的博客&#xff01;能与诸位在此相逢&#xff0c;我倍感荣幸。在这飞速更迭的时代&#xff0c;我们都渴望一方心灵净土&#xff0c;而 我的博客 正是这样温暖的所在。这里为你呈上趣味与实用兼具的知识&#xff0c;也…

【微知】tmux如何在一个会话的1个窗口中水平分割或者垂直分割窗口?(垂直 Ctrl + b, %; 切换Ctrl + b, 方向键; ctrl d关闭)

背景 除了直接创建窗口&#xff0c;还可以分割一个窗口。创建窗口参考兄弟篇&#xff1a;tmux如何在某个会话session中创建多个窗口&#xff1f;如何切换&#xff1f;&#xff08;Ctrlb c创建&#xff1b;Ctrlb 数字 切换&#xff1b;Ctrlb &关闭&#xff09; 命令 垂…

强化学习(赵世钰版)-学习笔记(7.时序差分学习)

本章是课程算法与方法中的第四章&#xff0c;介绍的时序差分学习算法是基于随机近似方法设计的强化学习方法&#xff0c;也是model-free的方法。 时序差分算法是一种近似估计策略状态值的算法&#xff0c;具体的形式如下&#xff1a; 本质上是在当前t时刻&#xff0c;被访问到的…

无公网IP也能远程控制Windows:Linux rdesktop内网穿透实战

文章目录 前言1. Windows 开启远程桌面2. Linux安装rdesktop工具3. Win安装Cpolar工具4. 配置远程桌面地址5. 远程桌面连接测试6. 设置固定远程地址7. 固定地址连接测试 前言 如今远程办公已经从一种选择变成了许多企业和个人的必修课&#xff0c;而如何在Linux系统上高效地访…

深度学习与大模型-矩阵

矩阵其实在我们的生活中也有很多应用&#xff0c;只是我们没注意罢了。 1. 矩阵是什么&#xff1f; 简单来说&#xff0c;矩阵就是一个长方形的数字表格。比如你有一个2行3列的矩阵&#xff0c;可以写成这样&#xff1a; 这个矩阵有2行3列&#xff0c;每个数字都有一个位置&a…

【实战ES】实战 Elasticsearch:快速上手与深度实践-8.2.1AWS OpenSearch无服务器方案

&#x1f449; 点击关注不迷路 &#x1f449; 点击关注不迷路 &#x1f449; 点击关注不迷路 文章大纲 8.2.1AWS OpenSearch 无服务器方案深度解析与实践指南1. Serverless架构的核心价值与行业趋势1.1 传统Elasticsearch集群的运维挑战1.2 Serverless技术演进路线技术特性对比…

使用 Arduino 和 ESP8266 Wi-Fi 模块发送电子邮件

使用 Arduino Uno 和 ESP8266 Wi-Fi 模块发送电子邮件 我们正在迈向物联网 (IoT) 世界。这项技术在电子和嵌入式系统中起着非常重要的作用。从任何微控制器或嵌入式系统发送电子邮件都是非常基本的事情,这在 IoT 中是必需的。因此,在本文中,我们将学习“如何使用 Wi-Fi 和…

jmeter-AES加密

AES(全称&#xff1a;Advanced Encryption Standard)对称加密算法&#xff0c;也就是加密和解密用到的密钥是相同的&#xff0c;这种加密方式加密速度非常快&#xff0c; 适合经常发送数据的场合&#xff0c;如&#xff1a;数据加密存储、网络通信加密等。 在进行接口测试或接…

四种 No-SQL

在一个常规的互联网服务中&#xff0c;读取与写入的比例大约是 100:1 到 1000:1。然而&#xff0c;从硬盘读取时&#xff0c;数据库连接操作耗时&#xff0c;99% 的时间花费在磁盘寻址上。 为了优化读取性能&#xff0c;非规范化的设计通过添加冗余数据或分组数据来引入。下述…

使用 Chrome Flags 设置(适用于 HTTP 站点开发)

使用 Chrome Flags 设置&#xff08;适用于 HTTP 站点开发&#xff09; 在 Chrome 地址栏输入&#xff1a;chrome://flags/在搜索框输入 “Insecure origins” 或 “Allow invalid certificates”。找到 “Insecure origins treated as secure” 选项&#xff08;或者 #allow-…

openharmony体验

openharmony5 去年已经出来了 如果以前做过android开发的&#xff0c;学起来不难&#xff0c;关键 1&#xff1a;环境 DevEco Studio 5.0.3 Beta2 https://developer.huawei.com/consumer/cn/deveco-studio/ win10_64bit CPU amd64(不是arm的) 2:安装 执行EXE 安装就行&#x…

【微知】plantuml在泳道图中如何将多个泳道框起来分组并且设置颜色?(box “浏览器“ #LightGreen endbox)

泳道分组并且着色 分组用 box和endbox &#xff0c;颜色用#xxx&#xff0c;标注用"xxx" box "浏览器" #LightGreen participant "浏览器1" as Browser participant "浏览器2" as Browser2 endboxparticipant "服务端" as …