前言
- 环境
Elasticsearch 7.10.1
ES 所在服务器操作系统为 Ubuntu 20.04
Windows 服务器版本为 Windows Server 2019
- 已将
Windows
的//172.31.19.143/es_snapshot
共享目录挂载到 ES 服务器的/mnt/winshare
目录 - Linux 挂载 Windows 共享目录参见:Ubuntu 20.04 读写 Windows 10 共享目录
批改 ES 服务配置
- 在
elasticsearch.yml
文件中增加如下配置,并重启 ES 服务
path.repo:
- /mnt/winshare
注册快照仓库
- 官网文档:https://www.elastic.co/guide/…
PUT /_snapshot/my_backup
{
"type": "fs",
"settings": {
"location": "/mnt/winshare/es_snapshot",
"max_snapshot_bytes_per_sec": "100mb", # 调整快照创立的速度,默认 40mb
"max_restore_bytes_per_sec": "200mb", # 调整快照复原的速度,默认无限度
}
}
- 查看所有注册的快照仓库
GET _snapshot/_all
- 调整机器复原分片速度和并发数
PUT _cluster/settings
{
"transient": {
"indices.recovery.max_bytes_per_sec": "200mb", # 默认 40mb
"cluster.routing.allocation.node_concurrent_recoveries": "5" # 默认 2
}
}
- 查看集群配置(包含默认配置)
GET _cluster/settings?flat_settings&include_defaults
创立快照
- 官网文档:https://www.elastic.co/guide/…
PUT /_snapshot/my_backup/snapshot_zt
{"indices": "zt_product_doc_index_20210223_3"}
- 查看一个
my_backup
仓库下的所有快照
GET _snapshot/my_backup/_all
- 查看
snapshot_zt
快照的概要状态
GET _snapshot/my_backup/snapshot_zt
- 查看
snapshot_zt
快照的具体状态
GET _snapshot/my_backup/snapshot_zt/_status
复原快照
- 官网文档:https://www.elastic.co/guide/…
POST /_snapshot/my_backup/snapshot_zt/_restore
{
"indices": "zt_product_doc_index_20210223_3",
"index_settings": {"index.number_of_replicas": 0},
"rename_pattern": "zt_product_doc_index_20210223_3",
"rename_replacement": "zt_product_doc_index_20210223_3_restore"
}
本文出自 qbit snap