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 快照备份和恢复,并排查可能的错误,确保集群数据安全无忧!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/984322.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【CSS3】筑基篇

目录 复合选择器后代选择器子选择器并集选择器交集选择器伪类选择器 CSS 三大特性继承性层叠性优先级 背景属性背景色背景图背景图平铺方式背景图位置背景图缩放背景图固定背景复合属性 显示模式显示模式块级元素行内元素行内块元素 转换显示模式 结构伪类选择器结构伪类选择器…

【MySQL】(4) 表的操作

一、创建表 语法&#xff1a; 示例&#xff1a; 生成的数据目录下的文件&#xff1a; 二、查看表结构 三、修改表 语法&#xff1a; 另一种改表名语法&#xff1a;rename table old_name1 to new_name1, old_name2 to new_name2; 示例&#xff1a; 四、删除表 语法&#xf…

C++:string容器(下篇)

1.string浅拷贝的问题 // 为了和标准库区分&#xff0c;此处使用String class String { public :/*String():_str(new char[1]){*_str \0;}*///String(const char* str "\0") // 错误示范//String(const char* str nullptr) // 错误示范String(const char* str …

基于Harbor构建docker私有仓库

Harbor 是一个开源的企业级容器镜像仓库&#xff0c;主要用于存储、签名和扫描容器镜像。Harbor 基于 Docker Registry 构建&#xff0c;并在此基础上增加了许多企业级特性&#xff0c;以满足企业对安全性、可扩展性和易用性的需求。Harbor 的架构由多个组件组成&#xff0c;包…

阿里发布新开源视频生成模型Wan-Video,支持文生图和图生图,最低6G就能跑,ComFyUI可用!

Wan-Video 模型介绍&#xff1a;包括 Wan-Video-1.3B-T2V 和 Wan-Video-14B-T2V 两个版本&#xff0c;分别支持文本到视频&#xff08;T2V&#xff09;和图像到视频&#xff08;I2V&#xff09;生成。14B 版本需要更高的 VRAM 配置。 Wan2.1 是一套全面开放的视频基础模型&…

运动控制卡--概述学习

目录 概述 技术背景 常见的运动控制卡分类&#xff1a; 国外品牌 国内品牌 各个品牌官网 国外品牌 国内品牌 概述 运动控制卡被称作控制卡&#xff0c;只是因为它做成卡的形式&#xff0c;可以插进工控机主板上&#xff0c;一般走pci或pcie通讯。运动控制卡负责接收计算…

网络编程-----服务器(多路复用IO 和 TCP并发模型)

一、单循环服务器模型 1. 核心特征 while(1){newfd accept();recv();close(newfd);}2. 典型应用场景 HTTP短连接服务&#xff08;早期Apache&#xff09;CGI快速处理简单测试服务器 3. 综合代码 #include <stdio.h> #include <sys/types.h> /* See NO…

Java【网络原理】(3)网络编程续

目录 1.前言 2.正文 2.1ServerSocket类 2.2Socket类 2.3Tcp回显服务器 2.3.1TcpEchoServer 2.3.2TcpEchoClient 3.小结 1.前言 哈喽大家好&#xff0c;今天继续进行计算机网络的初阶学习&#xff0c;今天学习的是tcp回显服务器的实现&#xff0c;正文开始 2.正文 在…

SpringMvc与Struts2

一、Spring MVC 1.1 概述 Spring MVC 是 Spring 框架的一部分&#xff0c;是一个基于 MVC 设计模式的轻量级 Web 框架。它提供了灵活的配置和强大的扩展能力&#xff0c;适合构建复杂的 Web 应用程序。 1.2 特点 轻量级&#xff1a;与 Spring 框架无缝集成&#xff0c;依赖…

web—HTML

什么是web ●Web:全球广域网&#xff0c;也称为万维网(www World Wide Web),能够通过浏览器访问的网站。 在浏览器中呈现精美的网页。 1.网页由那几部分组成&#xff1f; >文字、图片、视频、音频、超链接&#xff0c;&#xff0c;&#xff0c; 2.我们看到的网页&#xf…

php虚拟站点提示No input file specified时的问题及权限处理方法

访问站点&#xff0c;提示如下 No input file specified. 可能是文件权限有问题&#xff0c;也可能是“.user.ini”文件路径没有配置对&#xff0c;最简单的办法就是直接将它删除掉&#xff0c;还有就是将它设置正确 #配置成自己服务器上正确的路径 open_basedir/mnt/qiy/te…

INFINI Labs 产品更新 | Easysearch 增加异步搜索等新特性

INFINI Labs 产品更新发布&#xff01;此次更新&#xff0c;Easysearch 增加了新的功能和数据类型&#xff0c;包括 wildcard 数据类型、Point in time 搜索 API、异步搜索 API、数值和日期字段的 doc-values 搜索支持&#xff0c;Console 新增了日志查询功能。 INFINI Easyse…

关于OceanBase与CDH适配的经验分享

CDH是Cloudera早期推出的一个开源平台版本&#xff0c;它实质上成为了Apache Hadoop生态系统内公认的安装与管理平台&#xff0c;专为企业级需求量身打造。CDH为用户提供了即装即用的企业级解决方案。通过整合Hadoop与另外十多项关键开源项目&#xff0c;Cloudera构建了一个功能…

解决VScode 连接不上问题

问题 &#xff1a;VScode 连接不上 解决方案&#xff1a; 1、手动杀死VS Code服务器进程&#xff0c;然后重新尝试登录 打开xshell &#xff0c;远程连接服务器 &#xff0c;查看vscode的进程 &#xff0c;然后全部杀掉 [cxqiZwz9fjj2ssnshikw14avaZ ~]$ ps ajx | grep vsc…

[Python爬虫系列]bilibili

[Python爬虫系列]bilibili 具体逻辑 bv号 -> 处理多P视频 -> 拿到cid -> sign -> 请求下载&#xff0c;其中sign参考前人算法&#xff08;https://github.com/SocialSisterYi/bilibili-API-collect&#xff09; b站视频下载链接 https://api.bilibili.com/x/pl…

Linux——工具(3)git——版本控制器

一、git的使用意义 在实际项目中&#xff0c;我们往往写一个项目会经历很多个版本进行测试查缺补漏&#xff0c;然后再发行&#xff0c;但如果发行后我们发现仍出现问题&#xff0c;这时我们就需要撤回到上一个版本进行修改&#xff0c;可是如果我们此时不保存上一次的修改就不…

基于Python的商品销量的数据分析及推荐系统

一、研究背景及意义 1.1 研究背景 随着电子商务的快速发展&#xff0c;商品销售数据呈现爆炸式增长。这些数据中蕴含着消费者行为、市场趋势、商品关联等有价值的信息。然而&#xff0c;传统的数据分析方法难以处理海量、多源的销售数据&#xff0c;无法满足现代电商的需求。…

对WebSocket做一点简单的理解

1.概念 WebSocket 是基于 TCP 的一种新的网络协议。它实现了浏览器与服务器全双工通信——浏览器和服务器只需要完成一次握手&#xff0c;两者之间就可以创建持久性的连接&#xff0c; 并进行双向数据传输。 HTTP协议和WebSocket协议对比&#xff1a; HTTP是短连接 WebSocke…

【AI深度学习网络】Transformer时代,RNN(循环神经网络)为何仍是时序建模的“秘密武器”?

引言&#xff1a;什么是循环神经网络&#xff08;RNN&#xff09;&#xff1f; 循环神经网络&#xff08;Recurrent Neural Network, RNN&#xff09; 是一种专门处理序列数据&#xff08;如文本、语音、时间序列&#xff09;的深度学习模型。与传统神经网络不同&#xff0c;R…

蓝桥杯备考:图论初解

1&#xff1a;图的定义 我们学了线性表和树的结构&#xff0c;那什么是图呢&#xff1f; 线性表是一个串一个是一对一的结构 树是一对多的&#xff0c;每个结点可以有多个孩子&#xff0c;但只能有一个父亲 而我们今天学的图&#xff01;就是多对多的结构了 V表示的是图的顶点集…