概述将指定索引当前记录进行镜像备份,镜像文件可用于本集群数据恢复至镜像点,也可以将镜像恢复至新建的UDB集群。 新建备份前期准备- 搭建glusterfs分布式文件系统,用于建立镜像仓库;(glusterfs配置过程详见:《Glusterfs操作说明》)
- 在当前集群的每个节点上建相同路径的挂载目录,并挂载远程的glusgerfs共享目录;(详见:《Glusterfs操作说明》)
注: 当需要备份集群数据容量小于4T,搭建glusterfs可采用单节点单硬盘,恢复时可以将备份的单个硬盘接到新的集群中,进行本地仓库的数据恢复,也可以用单glusterfs集群进行; 大于4T建议建多节点多硬盘glusterfs集群,恢复过程也需要用glusterfs集群进行。 建ES镜像仓库curl -XPUT 'http://192.168.23.205:9200/_snapshot/my_backup' -d '{ "type": "fs", "settings": { "location": "/home/gdir", "compress": true, "max_snapshot_bytes_per_sec": "1024mb", "max_restore_bytes_per_sec": "1024mb" } }' 若要减少本过程对集群检索的影响,可以调整max_snapshot_bytes_per_sec,max_restore_bytes_per_sec,进行速度限制,反之可以将这两个只设置成足够大(1024mb=8G网络带宽)。 查看镜像仓库curl -XGET 'http://192.168.23.205:9200/_snapshot/my_backup' 返回 {"my_backup":{"type":"fs","settings":{"compress":"true","location":"/home/gdir","max_snapshot_bytes_per_sec":"1024mb","max_restore_bytes_per_sec":"1024mb"}}} 新建ES快照curl -XPUT "http://192.168.23.196:9200/_snapshot/my_backup/snapshot_1?wait_for_completion=true" -d '{ "indices": "article_type", "ignore_unavailable": "true", "include_global_state": false }' snapshot_1为快照名 "indices"不设置,默认将集群所有索引都进行快照 查看快照状态 curl -XGET 'http://192.168.23.205:9200/_snapshot/my_backup/snapshot_1/status' 返回 {"snapshots":[{"snapshot":"snapshot_1","indices":["data_all"],"state":"SUCCESS", "start_time":"2015-02-03T08:24:51.879Z","start_time_in_millis":1422951891879, "end_time":"2015-02-04T01:05:43.439Z", "end_time_in_millis":1423011943439, "duration_in_millis":60051560,"failures":[], "shards":{"total":24,"failed":0,"successful":24}}]} 查看快照建立过程是否有失败的分片 数据恢复curl -XPOST "http://192.168.23.205:9200/_snapshot/my_backup/snapshot_1/_restore" 恢复是否完成可以通过/_plugin/head查看分片是否初始化完成 恢复至新集群方式一:用glusterfs恢复前期准备与新建过程一致 建ES镜像仓库curl -XPUT 'http://192.168.23.205:9200/_snapshot/my_backup' -d '{ "type": "fs", "settings": { "location": "/home/gdir", "compress": true, "max_snapshot_bytes_per_sec": "1024mb", "max_restore_bytes_per_sec": "1024mb" } }' 目录与在备份时的一致。 查看镜像仓库 curl -XGET 'http://192.168.23.196:9200/_snapshot/my_backup' 返回 {"my_backup":{"type":"fs","settings":{"compress":"true","location":"/home/gdir","max_snapshot_bytes_per_sec":"1024mb","max_restore_bytes_per_sec":"1024mb"}}} 配置正确应直接能显示在老的集群中建立的镜像信息;若没有数据返回,则检查 - 目录是否一致
- 指定目录中是否有文件存储”metadata-snapshot_1 snapshot-snapshot_1”
数据恢复curl -XPOST "http://192.168.23.196:9200/_snapshot/my_backup/snapshot_1/_restore" 恢复是否完成可以通过/_plugin/head查看分片是否初始化完成 方式二:本地磁盘模式前期准备- 将建有镜像的磁盘挂接到新集群的一个节点;
- 只开启新集群的当前节点,确保新的集群运行正常。
建UDB镜像仓库 curl -XPUT 'http://192.168.23.205:9200/_snapshot/my_backup' -d '{ "type": "fs", "settings": { "location": "/home/gdir", "compress": true, "max_snapshot_bytes_per_sec": "1024mb", "max_restore_bytes_per_sec": "1024mb" } }' “location”指向带有镜像的硬盘目录 查看镜像仓库 curl -XGET 'http://192.168.23.196:9200/_snapshot/my_backup' 返回 {"my_backup":{"type":"fs","settings":{"compress":"true","location":"/home/gdir","max_snapshot_bytes_per_sec":"1024mb","max_restore_bytes_per_sec":"1024mb"}}} 配置正确应直接能显示在老的集群中建立的镜像信息;若没有数据返回,则检查 - 目录是否一致
- 指定目录中是否有文件存储”metadata-snapshot_1 snapshot-snapshot_1”
数据恢复curl -XPOST "http://192.168.23.196:9200/_snapshot/my_backup/snapshot_1/_restore" 恢复是否完成可以通过/_plugin/head查看分片是否初始化完成
|