es备份数据及恢复

发布 : 2022-08-10 分类 : 运维 浏览 :
  1. 在备份之前要在es/config/elasticsearch.yml添加仓库配置,并重启es

path.repo: [“/usr/share/elasticsearch/backup”]

  1. 在/usr/share/elasticsearch/backup下新建名为bro_backup的仓库
    1
    curl -u admin:admin -XPOST '127.0.0.1:9200/_snapshot/bro_backup' -H  'Content-Type: application/json' -d '{ "type": "fs",  "settings": { "location": "/usr/share/elasticsearch/backup", "compress": true, "chunk_size": "1g", "max_snapshot_bytes_per_sec": "50m", "max_restore_bytes_per_sec": "50m"}}'

max_snapshot_bytes_per_sec 和max_restore_bytes_per_sec 为了限制备份和恢复时的速度

  1. 备份数据
1
curl -u admin:admin -XPUT "127.0.0.1:9200/_snapshot/bro_backup/es_20220809?wait_for_completion=true"
  1. 查看备份信息
    1
    curl -u admin:admin -XGET http://127.0.0.1:9200/_snapshot/bro_backup/es_20220809

5.执行恢复命令,新节点的es 需要 执行 1-2 步骤

1
curl -XPOST '127.0.0.1:9200/_snapshot/bro_backup/es_20220809/_restore' -H 'Content-Type: application/json' -d'{ "ignore_unavailable": true, "include_global_state": false }'

6.查看恢复的数据

1
curl -u admin:admin '127.0.0.1:9200/_cat/indices?v'

设置 max_shards_per_node 分片

1
curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d '{"persistent" : {"cluster" : {"max_shards_per_node" : "5000"}}}'

ik 分词测试

1
curl --user elastic:zj2018 -H "Content-Type: application/json"  -XPOST  http://127.0.0.1:9200/_analyze -d'{"analyzer":"ik_max_word","text":"日子啊啊啊啊啊啊"}'

本文作者 : WGY
原文链接 : http://geeklive.cn/2022/08/10/elasticsearch-backup/undefined/elasticsearch-backup/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
留下足迹