参考:https://www.elastic.co/guide/en/elasticsearch/reference/7.3//modules-snapshots.html#_snapshot
简单记录,留作自用,仅供参考,如有错误,劳烦指正。有些说明简略了,请参考上述链接。
版本:7.3
一、单机:
1、服务器上创建/var/backups文件夹,chmod 777 权限
2、修改elasticsearch.yml文件,添加
path.repo: ["/var/backups"]
3、重启es
4、创建快照仓库
curl -XPUT "http://127.0.0.1:9200/_snapshot/backups" -H 'Content-Type: application/json' -d '{"type":"fs","settings":{"location":"/var/backups"}}'
5、备份
PUT http://127.0.0.1:9200/_snapshot/my_backup/snapshot_1
6、恢复
POST http://127.0.0.1:9200/_snapshot/my_backup/snapshot_1/_restore
7、查看备份信息
GET http://127.0.0.1:9200/_snapshot/my_backup/snapshot_1
8、删除备份
DELETE http://127.0.0.1:9200/_snapshot/my_backup/snapshot_2
二、集群:
1、创建共享文件夹,用作集群备份仓库共享
mkdir /var/backups
2、master节点
yum install nfs-utils
3、查看nfs服务状态
systemctl status nfs
4、编辑 vim /etc/exports ,添加下面路径
/var/backups/ (insecure,rw)
5、重新加载共享配置
systemctl reload nfs
showmount -e 127.0.0.1
6、配置follow node,本地创建文件夹 /var/backups ,挂载主节点共享目录
mount 127.0.0.1:/var/backups /var/backups
7、在主节点/var/ backups目录下创建或者删除文件,测试从节点是否跟随变换