当前位置: 首页 > news >正文

【Elasticsearch】索引快照并还原到其他集群

【Elasticsearch】索引快照并还原到其他集群

前提:es节点的所有用户id和组id都需要相同,最好在新建集群时指定用户id和组id,否则挂载后执行curl时会提示权限报错。
解决方法(gpt生成),不敢在生产尝试。
点我

一、安装共享文件系统

1.启动nfs
systemctl start nfs rpcbind
2. 编辑nfs文件

vi /etc/exports
/opt/public 192.168.113.0/24(rw,no_root_squash,insecure,sync)

3. 修改共享目录用户

比如elasticsearch使用的是es用户,用户权限这里要修改为es

chown es.es /opt/public

查看状态

exportfs -rv

查看挂载源

showmount -a

二、ES配置

1.各个节点挂载共享目录到repo指定目录,这里可不重启es

我这里配置的path.repo
path.repo: /home/elasticsearch-7.9.1/repository

mount -t nfs 192.168.113.101:/opt/public /home/elasticsearch-7.9.1/repository
2. 新建存储库
curl -u elastic -H 'Content-type: application/json' -XPUT 'http://192.168.113.101:9200/_snapshot/my_fs_backup' -d '{"type": "fs","settings": {"location": "my_fs_backup_location"}
}'
3. 新建快照(“metrics_38”)
curl -u elastic -H 'Content-type: application/json' -XPUT 'http://192.168.113.101:9200/_snapshot/my_fs_backup/metrics_38?wait_for_completion=true' -d '{"indices": "metrics_38"
}'

可以快照所有索引,使用“-”可以剔除指定的索引index1和index2
{
“indices”: “*,-index1,-index2”
}

4. 查看快照状态

curl -u elastic -H ‘Content-type: application/json’ -XGET ‘http://192.168.113.101:9200/_snapshot/my_fs_backup/metrics_38’

5. 后台查看数据

#repo.data: /home/elasticsearch-7.9.1/repository

cd /home/elasticsearch-7.9.1/repository/my_fs_backup_location
du -sh

三、还原到其他ES集群

索引名称不能冲突。

1. 拷贝文件到path.repo目录下
2. 在其他上还原es集群上,新建存储库
curl -H 'Content-type: application/json' -XPUT 'http://127.0.0.1:9200/_snapshot/my_fs_backup' -d '{"type": "fs","settings": {"location": "my_fs_backup_location"}
}'
4. 还原快照,等待green
curl -H 'Content-type: application/json' -XPOST 'http://127.0.0.1:9200/_snapshot/my_fs_backup/metrics_38/_restore' -d '{"indices": "metrics_38","rename_pattern": "(.+)"
}'
5. 批量还原
curl -H 'Content-type: application/json' -XPOST 'http://192.168.113.195:9200/_snapshot/my_fs_backup/metrics_38/_restore' -d '{"indices": "*","rename_pattern": "(.+)","rename_replacement": "restored-$1"
}'
http://www.lryc.cn/news/372099.html

相关文章:

  • QT--DAY1
  • DSP教学实验箱_数字图像处理_操作教程:5-1 图像旋转
  • MyBatis总结(2)- MyBatis实现原理(三)
  • 【保姆级教程】Linux 基于 Docker 部署 MySQL 和 Nacos 并配置两者连接
  • Dev C++ 安装及使用方法教程-干活多超详细
  • 无缝滚动的swiper
  • tvm实战踩坑
  • 计算机网络之网络层知识总结
  • 利用穿戴甲虚拟试戴技术提高销量和参与度
  • 后端|压缩Base64图片的两种方式
  • HCIP认证笔记(单选题)
  • 数据结构笔记-2、线性表
  • Linux基础IO【II】真的很详细
  • 【C++】模板及模板的特化
  • 2001-2023年上市公司数字化转型测算数据(含原始数据+处理代码+计算结果)
  • ICRA 2024:基于视觉触觉传感器的物体表⾯分类的Sim2Real双层适应⽅法
  • 代理模式(设计模式)
  • C++函数参数传递
  • 软考初级网络管理员_09_网络单选题
  • 曲线拟合 | 二次B样条拟合曲线
  • delphi FDMemTable1.SourceView遍历各行数据,取任意行数据无需Next移动指针了。TFDDatSView
  • 为什么选择 ABBYY FineReader PDF ?
  • php遇到的问题
  • 零基础入门学用Arduino 第二部分(二)
  • 旅游行业电商平台:数字化转型的引擎与未来发展趋势
  • Ubuntu 22.04安装 docker
  • 【Gitlab】访问默认PostgreSQL数据库
  • 乐鑫ESP32-C3芯片应用,启明云端WT32C3-S5模组:简化产品硬件设计
  • 算法刷题【二分法】
  • .NET MAUI Sqlite程序应用-数据库配置(一)