環境:
name3主機 elasticsearch-1.7.2
data1主機 elasticsearch-1.7.2curl
測試的elasticsearch都爲單機版,因此產生的快照文件都在一個目錄。
需求:
如今須要將name3中的數據都遷移到data1中elasticsearch
實現步驟:
一、編輯name3的配置文件,增長快照存儲地址
vi elasticsearch.yml
path.repo: ["/mnt/dfs/elastic/repo"]
二、重啓elasticsearch
ps -ef|grep elasticsearch
kill -9 xxxx
/opt/elasticsearch-1.7.2/bin/elasticsearch -Xmx32g -Xms32g -doop
3.註冊快照
curl -XPUT http://192.168.0.203:9200/_snapshot/my_repo -d '
{
"type": "fs",
"settings": {
"location": "/mnt/dfs/elastic/repo"
}
}'測試
執行:
curl http://localhost:9200/_snapshot 查看結果
執行快照請求--備份(快照名稱:snapshot_20190926)
curl -XPUT http://localhost:9200/_snapshot/my_repo/snapshot_20190926
查看執行快照的結果
curl http://localhost:9200/_snapshot/my_repo/snapshot_20190926
4.將快照遷移到另外一個主機--data1
scp /mnt/dfs/elastic/repo root@data1:/var/elastic/
#修改遷移的目標主機data1的elasticsearch.yml,一樣增長path.repo
vi elasticsearch.yml
path.repo = /var/elastic/repo
#重啓elasticsearch,註冊快照
curl -XPUT http://192.168.0.101:9200/_snapshot/my_repo -d '
{
"type": "fs",
"settings": {
"location": "/var/elastic/repo"
}
}'
#在目標機上執行還原操做
curl -XPOST http://localhost:9200/_snapshot/my_repo/snapshot_20190926/_restoreurl
若是將快照備份到hdfs須要安裝hdfs相關的插件:repository-hdfs插件
構建hdfs快照倉庫地址rest
PUT http://host:9200/_snapshot/backup { "type": "hdfs", "settings": { "uri": "hdfs://host:9000", "path": "/elasticsearch", "conf_location": "/etc/hadoop/hdfs-site.xml" } }xml
查看快照恢復進度:索引
# 查看全部索引的恢復進度
curl -XGET http://192.168.0.101:9200/_recovery/hadoop
# 查看索引kc21k1的恢復進度 curl -XGET http://192.168.0.101:9200/_recovery/kc21k1