ES创建仓库与恢复快照

一、停止ES集群

1)禁止分片自动分布

 curl -H "Content-Type: application/json" -XPUT 'http://192.168.68.128:9202/_cluster/settings'  -d '{"transient":{"cluster.routing.allocation.enable": "none"}}'

2)执行同步刷新

curl -H "Content-Type: application/json" -XPOST 'http://192.168.68.128:9202/_flush/synced'

3)查看进程

ps -ef | grep elastic

在这里插入图片描述
4)停止es的进程

  Kill -9 4844

二、配置快照仓库

1)分别修改三个ES的elasticsearch.yml
vim elasticsearch.yml

 path.repo: [/opt/es-cluster/bh_backup”]

在这里插入图片描述
2)创建 bh_backup目录

  cd /opt/es-cluster
  mkdir -r bh_backup/group
  mkdir -r bh_backup/controller

3)给目录赋权

chown elasticsearch:elasticsearch  bh_backup

三、重启es集群

1)重启集群

cd /opt/es-cluster/es1/bin
./elasticsearch -d 
cd /opt/es-cluster/es2/bin
./elasticsearch -d 
cd /opt/es-cluster/es3/bin
./elasticsearch -d 

2)查看集群状态和分片情况

curl -H "Content-Type: application/json" -X GET "http://192.168.68.128:9202/_cat/health?pretty"
curl -H "Content-Type: application/json" -X GET "http://192.168.68.128:9202/_cat/recovery?pretty"

3)启用分片自动分片

curl -H "Content-Type: application/json" -XPUT 'http://192.168.68.128:9202/_cluster/settings'  -d '{"transient":{"cluster.routing.allocation.enable": "all"}}'

四、创建本地仓库

1)创建集团的快照仓库

 curl -H "Content-Type: application/json" -XPUT 'http://192.168.68.128:9202/_snapshot/group' -d '{
    "type": "fs",
    "settings": {
        "location": "/opt/es-cluster/bh_backup/group",
        "compress": true
    }
}'

2)创建实际控制人的快照仓库

curl -H "Content-Type: application/json"  -XPUT 'http://192.168.68.128:9202/_snapshot/controller' -d '{
    "type": "fs",
    "settings": {
        "location": "/opt/es-cluster/bh_backup/controller",
        "compress": true
    }
}'

在这里插入图片描述

五、将快照解压复制到仓库目录

1)解压快照文件

unzip kg.group_v2.zip
unzip kg.controller.zip
cp -r ./back_new/* /opt/es-cluster/bh_backup/group 
cp -r ./kg.controller/* /opt/es-cluster/bh_backup/controller

2)赋权给快照路径

chown -R  elasticsearch:elasticsearch /opt/es-cluster/bh_backup/group
chown -R  elasticsearch:elasticsearch /opt/es-cluster/bh_backup/controller

六、从镜像中恢复快照数据

1)查询group仓库下的快照信息

curl -XGET "http://192.168.68.128:9202/_snapshot/group/_all?pretty"

2)恢复快照数据

 curl -H "Content-Type: application/json" -XPOST  'http://192.168.68.128:9202/_snapshot/group/es_snapshot/_restore' -d '{
    "indices": "kg.group_v2_20201029",
    "index_settings": {
    "index.number_of_replicas": 1
    },
    "ignore_index_settings": [
    "index.refresh_interval"
    ]
}'
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值