Elasticsearch AWS S3 备份数据

按照 Elastic 官方给出的 Recommanded S3 Permissions 直接配置即可。

Recommanded S3 Permissions:

https://www.elastic.co/guide/en/elasticsearch/plugins/current/repository-s3-repository.html#repository-s3-permissions

备份步骤:

1. 需要安装的插件 (推荐每台es节点都安装,并重启服务)

bin/elasticsearch-plugin install repository-s3

2. 配置访问S3账号与密码

#ACCESS-KEY
/opt/elasticsearch/bin/elasticsearch-keystore add s3.client.default.access_key

#SECRET-KEY

/opt/elasticsearch/bin/elasticsearch-keystore add s3.client.default.secret_key

3. 创建ES在Amazon S3存储库实例

curl -XPUT 'http://localhost:9200/_snapshot/backup' -H 'Content-Type: application/json' -d '{ "type": "s3", "settings": { "bucket": "indexs-backup"} }' 

4. 确认备份仓库是否创建成功

curl -XPOST http://localhost:9200/_snapshot/backup/_verify?pretty

5. 查看创建的存储仓库

curl -XGET localhost:9200/_snapshot/backup?pretty

6. 备份所有索引

curl -XPUT http://127.0.0.1:9200/_snapshot/backup/snapshot_all

7. 备份部分索引

curl -XPUT 'http://localhost:9200/_snapshot/backup/index-201807' -H 'Content-Type: application/json' -d '{ "indices": "index-201807" }'

备份多个索引:

{

   "indices": "products,index_1,index_2",
   "ignore_unavailable": true,
   "include_global_state": false

}

8. 查看快照信息

curl -XGET 'http://localhost:9200/_snapshot/backup/_all'?pretty

9. 恢复索引数据:
curl -XPOST 'http://localhost:9200/_snapshot/backup/index-201807/_restore


10. 查看恢复状态:

GET http://127.0.0.1:9200/_recovery/index-201807
GET http://127.0.0.1:9200/_recovery/

11. 删除一个快照存储桶:

curl -XDELETE localhost:9200/_snapshot/backup/index-201807?pretty

12. 结束




猜你喜欢

转载自blog.csdn.net/feng12345zi/article/details/81006440