关于amazon-web-services:ES-快照到-S3-并从-Windows-共享目录恢复qbit

51次阅读

共计 3003 个字符,预计需要花费 8 分钟才能阅读完成。

前言

  • 业务须要将 Elasticsearch 快照到 AWS S3,再将快照拷贝到 Windows 零碎,并复原到 Elasticsearch。如下图所示:

  • 环境
Elasticsearch 7.10.1
Windows Server 2019
Ubuntu 20.04(ES 宿主)

ES 集群 1 装置 S3 插件

  • 官网文档:https://www.elastic.co/guide/…
  • 应在 ES 集群的所有节点上装置插件
  • 下载 S3 插件和 SHA hash,并上传到 ES 服务器
  • 查看并校验
# ll -ah
total 4.6M
drwxr-xr-x 2 qhy qhy 4.0K Mar  9 01:55 ./
drwxr-xr-x 7 qhy qhy 4.0K Mar  9 01:50 ../
-rw-rw-r-- 1 qhy qhy 4.6M Mar  9 01:55 repository-s3-7.10.1.zip
-rw-rw-r-- 1 qhy qhy  154 Mar  9 01:55 repository-s3-7.10.1.zip.sha512

# shasum -a 512 -c repository-s3-7.10.1.zip.sha512 
repository-s3-7.10.1.zip: OK
  • 装置
# /usr/share/elasticsearch/bin/elasticsearch-plugin install file:///home/qhy/es_down/repository-s3-7.10.1.zip
-> Installing file:///home/qhy/es_down/repository-s3-7.10.1.zip
-> Downloading file:///home/qhy/es_down/repository-s3-7.10.1.zip
[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission getClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.net.SocketPermission * connect,resolve
* java.util.PropertyPermission es.allow_insecure_settings read,write
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed repository-s3
  • 重启 ES 服务

ES 集群 1 增加 KEY

  • 应在 ES 集群的所有节点上增加 key
  • 查看有哪些 key
/usr/share/elasticsearch/bin/elasticsearch-keystore list
  • 增加 access_key
/usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.access_key
  • 增加 secret_key
/usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.secret_key
  • 重载配置
POST _nodes/reload_secure_settings

创立快照仓库

  • 官网文档:https://www.elastic.co/guide/…
  • 留神中国区不反对 region,用 endpoint 代替
PUT _snapshot/my_s3_repository
{
  "type": "s3",
  "settings": {
    "bucket": "zt-hadoop-cn-northwest-1",
    "endpoint": "s3.cn-northwest-1.amazonaws.com.cn",
    "max_snapshot_bytes_per_sec": "200mb",  # 调整快照创立的速度,默认 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_s3_repository/snapshot_zt
{"indices": "zt_product_doc_index_20210223_3"}
  • 查看一个 my_s3_repository 仓库下的所有快照
GET _snapshot/my_s3_repository/_all
  • 查看 snapshot_zt 快照的概要状态
GET _snapshot/my_s3_repository/snapshot_zt
  • 查看 snapshot_zt 快照的具体状态
GET _snapshot/my_s3_repository/snapshot_zt/_status

复原快照

  • 官网文档:https://www.elastic.co/guide/…
POST /_snapshot/my_s3_repository/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"
}
  • 减少正本
PUT zt_product_doc_index_20210223_3_restore/_settings
{"index.number_of_replicas" : "1"}

本文出自 qbit snap

正文完
 0