es备份数据及恢复
- 在备份之前要在es/config/elasticsearch.yml添加仓库配置,并重启es
path.repo: [“/usr/share/elasticsearch/backup”]
- 在/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 | curl -u admin:admin -XPUT "127.0.0.1:9200/_snapshot/bro_backup/es_20220809?wait_for_completion=true" |
- 查看备份信息
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 许可协议。转载请注明出处!