Easysearch、Elasticsearch、Amazon OpenSearch 快照兼容对比

news2024/9/19 6:56:49

启动集群

Easysearch

sysctl -w vm.max_map_count=262144

Amazon OpenSearch

Elasticsearch

由于这个docker compose没有关于kibana的配置,所以我们还是用Console添加原生的Elasticsearch集群请添加图片描述

集群信息

请添加图片描述

快照还原的步骤

快照前的准备

插件安装

本次测试选择把索引快照备份到Amazon S3,所以需要使用S3 repository plugin,这个插件添加了对使用 Amazon S3 作为快照/恢复存储库的支持。

Easysearch和OpenSearch集群自带了这个插件,所以无需额外安装。

对于自己部署的三节点Elasticsearch则需要进入每一个节点运行安装命令然后再重启集群,建议使用自动化运维工具来做这步,安装命令如下:

sudo bin/elasticsearch-plugin install repository-s3

如果不再需要这个插件,可以这样删除。

sudo bin/elasticsearch-plugin remove repository-s3

由于需要和Amazon Web Services打交道,所以我们需要设置IAM凭证,这个插件可以从EC2 IAM instance profile,ECS task role 以及EKS的Service account读取相应的凭证。

对于托管的Amazon OpenSearch来说,我们无法在托管的EC2上绑定我们的凭证,所以需要新建一个OpenSearchSnapshotRole,然后通过当前的用户把这个角色传递给服务,也就是我们说的IAM:PassRole。

创建OpenSearchSnapshotRole,策略如下:

{
  "Version": "2012-10-17",
  "Statement": [{
      "Action": [
        "s3:ListBucket"
      ],
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::bucket-name"
      ]
    },
    {
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject"
      ],
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::bucket-name/*"
      ]
    }
  ]
}

信任关系如下:

{
  "Version": "2012-10-17",
  "Statement": [{
      "Effect": "Allow",
      "Principal": {
        "Service": "es.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

然后在我们的IAM user上加上PassRole的权限,这样我们就可以把OpenSearchSnapshotRole传递给OpenSearch集群。

{
  "Version": "2012-10-17",
  "Statement": [{
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "arn:aws:iam::123456789012:role/OpenSearchSnapshotRole"
    }
  ]
}

注册存储库

在源集群执行注册

PUT /_snapshot/snapshot-repo-name
{
  "type": "s3",
  "settings": {
    "bucket": "<bucket-name>",
    "base_path": "<bucket-prefix>",

在目标集群同样执行这个语句,为了防止覆盖源集群存储库的数据,将 “readonly”: true 添加到"settings" PUT 请求中,这样就只有一个集群具有对存储库的写入权限。

PUT /_snapshot/snapshot-repo-name
{
  "type": "s3",
  "settings": {
    "bucket": "<bucket-name>",
    "base_path": "<bucket-prefix>",
    "readonly": true,

对于OpenSearch来说,还需要执行passrole,所以还需要添加role_arn这个字段,由于IAM:PassRole需要对HTTP 请求做signV4日签名,所以这部常常使用Postman来完成。把角色传递过去之后,接下来的快照还原操作就可以在OpenSearch Dashboard中进行操作了。

在这里插入图片描述

需要注意的是,需要在auth这里输入AccessKey,SecretKey,AWS Region,Service Name(es)来做SignV4的签名。
在这里插入图片描述

请求体如下:

{
  "type": "s3",
  "settings": {
    "bucket": "<bucket-name>",
    "base_path": "<bucket-prefix>",
    "readonly": true,
    "role_arn": "arn:aws:iam::123456789012:role/OpenSearchSnapshotRole"
  }
}

  • 查看所有注册的存储库
    • GET _snapshot:这个命令返回所有已注册的快照存储库列表及其基本信息。
GET _snapshot
{
  "es_repository": {
    "type": "s3",
    "settings": {
      "bucket": "your-s3-bucket-name",
      "region": "your-s3-bucket-region"
    }
  }
}
  • 查看特定存储库的详细信息
    GET _snapshot/es_repository:这个命令返回名为es_repository的存储库的详细配置信息,包括存储桶名称、区域和其他设置。
GET _snapshot/es_repository
{
  "es_repository": {
    "type": "s3",
    "settings": {
      "bucket": "your-s3-bucket-name",
      "region": "your-s3-bucket-region",
      "access_key": "your-access-key",
      "secret_key": "your-secret-key"
    }
  }
}
  • 查看特定存储库中的快照
    GET _cat/snapshots/es_repository?v:这个命令返回es_repository存储库中的所有快照及其详细信息,包括快照ID、状态、开始时间、结束时间、持续时间、包含的索引数量、成功和失败的分片数量等。
GET _cat/snapshots/es_repository?v
id                     status start_epoch start_time end_epoch end_time duration indices successful_shards failed_shards total_shards
snapshot_1             SUCCESS 1628884800 08:00:00   1628888400 09:00:00 1h       3       10                0             10
snapshot_2             SUCCESS 1628971200 08:00:00   1628974800 09:00:00 1h       3       10                0             10

创建索引快照

# PUT _snapshot/my_repository/<my_snapshot_{now/d}>
PUT _snapshot/my_repository/my_snapshot
{
  "indices": "my-index,logs-my_app-default",
}

根据快照的大小不同,完成快照可能需要一些时间。默认情况下,create snapshot API 只会异步启动快照过程,该过程在后台运行。要更改为同步调用,可以将 wait_for_completion 查询参数设置为 true

PUT _snapshot/my_repository/my_snapshot?wait_for_completion=true

另外还可以使用 clone snapshot API 克隆现有的快照。要监控当前正在运行的快照,可以使用带有 _current 请求路径参数的 get snapshot API。

GET _snapshot/my_repository/_current

如果要获取参与当前运行快照的每个分片的完整详细信息,可以使用 get snapshot status API。

GET _snapshot/_status

成功创建快照之后,就可以在S3上看到备份的数据块文件,这个是正确的快照层级结构:
在这里插入图片描述

需要注意的是, “base_path”: ""这里最好不要加/,虽然不影响同集群迁移,这个会为我们在不同厂商的搜索引擎中迁移遇到问题,可能是这样的,所以需要注意。请添加图片描述所以在Open Search中还原Elasticsearch就遇到了这个问题:

{
  "error": {
    "root_cause": [
      {
        "type": "snapshot_missing_exception",
        "reason": "[easy_repository:2/-jOQ0oucQDGF3hJMNz-vKQ] is missing"
      }
    ],
    "type": "snapshot_missing_exception",
    "reason": "[easy_repository:2/-jOQ0oucQDGF3hJMNz-vKQ] is missing",
    "caused_by": {
      "type": "no_such_file_exception",
      "reason": "Blob object [11111/indices/7fv2zAi4Rt203JfsczUrBg/meta-YGnzxZABRBxW-2vqcmci.dat] not found: The specified key does not exist. (Service: S3, Status Code: 404, Request ID: R71DDHX4XXM0434T, Extended Request ID: d9M/HWvPvMFdPhB6KX+wYCW3ZFqeFo9EoscWPkulOXWa+TnovAE5PlemtuVzKXjlC+rrgskXAus=)"
    }
  },
  "status": 404
}

恢复索引快照

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

各个集群的还原

  1. Elasticsearch 7.10.2 的快照可以还原到Easysearch和Amazon OpenSearch

  2. 从Easysearch 1.8.2还原到Elasticsearch 7.10.2报错如下:

{
  "error": {
    "root_cause": [
      {
        "type": "snapshot_restore_exception",
        "reason": "[s3_repository:1/a2qV4NYIReqvgW6BX_nxxw] cannot restore index [my_indexs] because it cannot be upgraded"
      }
    ],
    "type": "snapshot_restore_exception",
    "reason": "[s3_repository:1/a2qV4NYIReqvgW6BX_nxxw] cannot restore index [my_indexs] because it cannot be upgraded",
    "caused_by": {
      "type": "illegal_state_exception",
      "reason": "The index [[my_indexs/ALlTCIr0RJqtP06ouQmf0g]] was created with version [1.8.2] but the minimum compatible version is [6.0.0-beta1]. It should be re-indexed in Elasticsearch 6.x before upgrading to 7.10.2."
    }
  },
  "status": 500
}
  1. 从Amazon OpenSearch 2.1.3还原到Elasticsearch 7.10.2报错如下(无论是否开启兼容模式):
{
  "error": {
    "root_cause": [
      {
        "type": "snapshot_restore_exception",
        "reason": "[aos:2/D-oyYSscSdCbZFcmPZa_yg] the snapshot was created with Elasticsearch version [36.34.78-beta2] which is higher than the version of this node [7.10.2]"
      }
    ],
    "type": "snapshot_restore_exception",
    "reason": "[aos:2/D-oyYSscSdCbZFcmPZa_yg] the snapshot was created with Elasticsearch version [36.34.78-beta2] which is higher than the version of this node [7.10.2]"
  },
  "status": 500
}
  1. 从Easysearch 1.8.2还原到Amazon OpenSearch2.13报错如下(无论是否开启兼容模式):
{
  "error": {
    "root_cause": [
      {
        "type": "snapshot_restore_exception",
        "reason": "[easy_repository:2/LE18AWHlRJu9rpz9BJatUQ] cannot restore index [my_indexs] because it cannot be upgraded"
      }
    ],
    "type": "snapshot_restore_exception",
    "reason": "[easy_repository:2/LE18AWHlRJu9rpz9BJatUQ] cannot restore index [my_indexs] because it cannot be upgraded",
    "caused_by": {
      "type": "illegal_state_exception",
      "reason": "The index [[my_indexs/VHOo7yfDTRa48uhQvquFzQ]] was created with version [1.8.2] but the minimum compatible version is OpenSearch 1.0.0 (or Elasticsearch 7.0.0). It should be re-indexed in OpenSearch 1.x (or Elasticsearch 7.x) before upgrading to 2.13.0."
    }
  },
  "status": 500
}

以下是兼容性对比,每行第一列代表源集群,第一行代表目标集群:

快照兼容对比Easysearch 1.8.2Elasticsearch 7.10.2OpenSearch 2.13
Easysearch 1.8.2兼容不兼容不兼容
Elasticsearch 7.10.2兼容兼容兼容
OpenSearch 2.13不兼容不兼容兼容

Elasticsearch的兼容列表官方的列表如下:
在这里插入图片描述

参考文献

开始使用 Elastic Stack 和 Docker Compose:第 1 部分
https://www.elastic.co/cn/blog/getting-started-with-the-elastic-stack-and-docker-compose

Docker Compose 部署多节点Elasticsearch

https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docker.html#docker-compose-file

repository-s3 教程

https://www.elastic.co/guide/en/elasticsearch/reference/8.14/repository-s3.html

https://www.elastic.co/guide/en/elasticsearch/plugins/7.10/repository-s3.html

snapshot-restore

https://www.elastic.co/guide/en/elasticsearch/reference/7.10/snapshot-restore.html

在亚马逊 OpenSearch 服务中创建索引快照

https://docs.amazonaws.cn/zh_cn/opensearch-service/latest/developerguide/managedomains-snapshots.html#managedomains-snapshot-restore

教程:迁移至 Amazon OpenSearch Service

https://docs.amazonaws.cn/zh_cn/opensearch-service/latest/developerguide/migration.html

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

力扣1696.跳跃游戏 VI

力扣1696.跳跃游戏 VI 递推 class Solution {public:int maxResult(vector<int>& nums, int k) {int n nums.size();vector<int> f(n);f[0] nums[0];for(int i1;i<n;i)f[i] *max_element(f.begin() max(i-k,0),f.begin() i) nums[i];return f[n-1];}…

【Manim动画教程】——基本几何 【弧-上】

1.标注点&#xff08;AnnotationDot&#xff09; 具有较大半径和粗体笔触的点&#xff0c;用于注释场景。 class AnnotationDot(radius0.10400000000000001, stroke_width5, stroke_colorManimColor(#FFFFFF), fill_colorManimColor(#58C4DD), **kwargs) 实例代码&#xff…

npm install报错:npm error ERESOLVE could not resolve

从git上拉取一个新vue项目下来&#xff0c;在npm install时报错&#xff1a;npm error ERESOLVE could not resolve 有网友分析原因是因为依赖冲突导致报错&#xff0c;解决方法如下&#xff1a; # --legacy-peer-deps&#xff1a;安装时忽略所有peerDependencies&#xff0c…

Serverless技术的市场调研与发展分析

目录 一、 Serverless基础 1.1 Serverless产生的背景 1.2 什么是Serverless 1.3 Serverless架构优势 1.3.1 按需使用的资源管理 1.3.2 简化业务运维复杂度 1.4 Serverless和Service Mesh相同点 1.5 Serverless基础架构 1.5.1 函数管理 1.5.2 事件触发器 1.5.3 函数的…

加载数据集(Dataset and Dataloader)

dataset主要是用于构造数据集&#xff08;支持索引&#xff09;&#xff0c;dataloader可以拿出一个mini-batch供我们快速使用。 一&#xff1a;上一节知识 一下是我们上一节提到的糖尿病数据集&#xff0c;其中在提到数据加载的时候&#xff0c;我们没有使用mini-batch的方法…

Linux系统下载htop

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、在Debian/Ubuntu上安装htop1.1更新包列表1.2 安装htop 二、在CentOS/RHEL上安装htop2.1.启用EPEL仓库2.2 安装htop 三、在Fedora上安装htop3.1.安装htop 四…

GraphRAG+ollama+LM Studio+chainlit

这里我们进一步尝试将embedding模型也换为本地的&#xff0c;同时熟悉一下流程和学一些新的东西 1.环境还是用之前的&#xff0c;这里我们先下载LLM 然后你会在下载nomic模型的时候崩溃&#xff0c;因为无法搜索&#xff0c;无法下载 解决办法如下lm studio 0.2.24国内下载…

升级pnpm 升级node.js 解决安装nodejs多版本时显示 is not yet released or available

第一部分&#xff1a;升级pnpm 1、使用命令查看本地安装的pnpm版本 pnpm -v2 使用命令安装指定版本的pnpm npm install -g pnpm8.9.0也可以使用以下命令安装最新版本的pnpm: npm install -g pnpmlatest安装后可以使用pnpm -v 查看是否升级成功 第二部分&#xff1a;升级n…

非线性支持向量机(SVM)

理论知识推导 支持向量机&#xff08;SVM&#xff09;是一种用于分类和回归分析的监督学习模型。在处理非线性数据时&#xff0c;线性SVM可能无法很好地分离数据。为了解决这个问题&#xff0c;我们使用核函数将低维空间的非线性数据映射到高维空间&#xff0c;使得在高维空间…

邵楠:数据湖存储的现状和未来趋势

近几年数据湖的概念非常火热&#xff0c;但是数据湖的定义并不统一&#xff0c;我们先看下数据湖的相关定义。 Wikipedia对数据湖的定义&#xff1a; 数据湖是指使用大型二进制对象或文件这样的自然格式储存数据的系统。它通常把所有的企业数据统一存储&#xff0c;既包括源系…

生产力工具|Endnote 21 Macwin版本安装

一、软件下载&#xff1a; &#xff08;一&#xff09;mac版本 Endnote 21版本下载&#xff1a;点击下载 Endnote 20版本下载&#xff1a;点击下载 Endnote X9版本下载&#xff1a;点击下载 &#xff08;二&#xff09;Endnote 20 Win版本 第一步&#xff1a;安装好官网软…

分享:一次性查找多个PDF文件,如何根据txt文本列出的文件名批量查找指定文件夹里的文件,并复制到新的文件夹,不需要写任何代码,点点鼠标批量处理一次性搞定

简介&#xff1a; 该文介绍了一个批量查找PDF文件&#xff08;不限于找PDF&#xff09;的工具&#xff0c;用于在多级文件夹中快速查找并复制特定文件。用户可以加载PDF库&#xff0c;输入文件名列表&#xff0c;设置操作参数&#xff08;如保存路径、复制或删除&#xff09;及…

树莓派4B从装系统raspbian到vscode远程编程(python)

1、写在前面 前面用的一直是Ubuntu系统&#xff0c;但是遇到一个奇葩的问题&#xff1a; 北通手柄在终端可以正常使用&#xff0c;接收到数据 但在python程序中使用pygame库初始化时总是报错&#xff1a;Invalid device number&#xff0c;检测不到手柄 经过n次重装系统&am…

【.NET全栈】ASP.NET开发Web应用——计算器

文章目录 一、简单计算器二、复杂计算器 一、简单计算器 新建Web应用项目&#xff0c;窗体页面 窗体设计代码&#xff1a; <% Page Language"C#" AutoEventWireup"true" CodeBehind"Default.aspx.cs" Inherits"AdoDemo.Default"…

打造智慧图书馆:AI视频技术助力图书馆安全与秩序管理

一、背景需求 随着信息技术的飞速发展&#xff0c;图书馆作为重要的知识传播场所&#xff0c;其安全管理也面临着新的挑战。为了确保图书馆内书籍的安全、维护读者的阅读环境以及应对突发事件&#xff0c;TSINGSEE青犀旭帆科技基于EasyCVR视频监控汇聚平台技术与AI视频智能分析…

《0基础》学习Python——第十九讲__爬虫\<2>

一、用get请求爬取一般网页 首先由上节课我们可以找到URL、请求方式、User-Agent以及content-type 即&#xff1a;在所在浏览器页面按下F12键&#xff0c;之后点击网路-刷新&#xff0c;找到第一条双击打开标头即可查看上述所有内容&#xff0c;将上述URL、User-Agent所对应的…

WGS84经纬度坐标 GCJ02火星坐标 BD09百度坐标互相转换

WGS84经纬度坐标 GCJ02火星坐标 BD09百度坐标互相转换 背景&#xff1a;uniapp做的微信小程序&#xff0c;使用到了相机拍照并获取位置坐标信息&#xff1b;在腾讯地图上展示坐标点位置信息&#xff1b; 由于业务需要我们的PC端用的不是腾讯地图&#xff0c;需要使用WGS84坐标或…

目标检测 | YOLO v1、YOLO v2、YOLO v3与YOLO v3 SPP理论讲解

☀️教程&#xff1a;霹雳吧啦Wz ☀️链接&#xff1a;https://www.bilibili.com/video/BV1yi4y1g7ro?p1&vd_sourcec7e390079ff3e10b79e23fb333bea49d 一、YOLO v1 针对于two-stage目标检测算法普遍存在的运算速度慢的缺点&#xff0c;YOLO创造性的提出了one-stage目标检测…

Jupyter notebook如何快速的插入一张图片?如何控制插入图片的缩放、靠左展示(ChatGPT)

在Jupyter Notebook中&#xff0c;你可以使用Markdown语法快速插入图片&#xff0c;并且可以通过HTML标签来控制图片的展示方式和缩放。 注意&#xff1a;以下所有操作都有一个前提&#xff0c;即选择Cell-CellType-Markdown 1. 快速插入图片 要在Jupyter Notebook中插入图…

【Langchain大语言模型开发教程】模型、提示和解析

&#x1f517; LangChain for LLM Application Development - DeepLearning.AI 学习目标 1、使用Langchain实例化一个LLM的接口 2、 使用Langchain的模板功能&#xff0c;将需要改动的部分抽象成变量&#xff0c;在具体的情况下替换成需要的内容&#xff0c;来达到模板复用效…