es備份遷移到另外的新機器


 

1.在原來的機器上進行備份(我這里備份只保留2天,所以多了些處理腳本)
##創建備份倉庫目錄
curl -H "Content-Type: application/json" -XPUT http://192.168.1.136:19200/_snapshot/esbackup -d'{
"type": "fs",
"settings": {
"location": "/home/yeemiao/single_elasticsearch/esbak"
}
}'

##備份
curl -H "Content-Type: application/json" -XPUT http://192.168.1.136:19200/_snapshot/esbackup/snapshot_20190815


2.查看備份情況
curl -X GET "http://192.168.1.136:19200/_snapshot/esbackup/_all?pretty"
我這里已經有備份,查看備份情況
[yeemiao@localhost esbak]$ curl -X GET "http://192.168.1.136:19200/_snapshot/esbackup/_all?pretty"
{
"snapshots" : [
{
"snapshot" : "snapshot_20190815",
"uuid" : "jZk8QYgISMmkc1qpNB4BZw",
"version_id" : 6050099,
"version" : "6.5.0",
"indices" : [
"reservation_hxl",
"reservation",
"vacc_update",
"reservation_new",
"child_inocexamine_student_inoculation1",
"child_inocexamine_vacc",
"hxl_update",
"bak01_hxl_test",
"child_inocexamine_student",
"bak_hxl_test",
"child_inocexamine_student_inoculation",
"inoculate_new",
"update",
"bak02_hxl_test",
"inoculate",
".security-6"
],
"include_global_state" : true,
"state" : "IN_PROGRESS",
"start_time" : "2019-08-15T05:45:40.443Z",
"start_time_in_millis" : 1565847940443,
"end_time" : "1970-01-01T00:00:00.000Z",
"end_time_in_millis" : 0,
"duration_in_millis" : -1565847940443,
"failures" : [ ],
"shards" : {
"total" : 0,
"failed" : 0,
"successful" : 0
}
}
]
}

3.將es備份目錄打包,然后上傳到新部署的機器上面
[yeemiao@localhost single_elasticsearch]$ cd /home/yeemiao/single_elasticsearch
tar -czvf esbak20190815.tar ./esbak
scp esbak20190815.tar yeemiao@192.168.1.134:/tmp/


4.新機器安裝部署es
安裝步驟省略,特別注意如下參數必須跟原來機器一致,因為我們等會將原來機器的備份文件加壓到該目錄
path.repo: /home/yeemiao/single_elasticsearch/esbak


5.將原主機備份的文件解壓到新機器path.repo參數指定的目錄
[yeemiao@localhost tmp]$ cd /tmp/
[yeemiao@localhost tmp]$ tar -xvf esbak20190815.tar
[yeemiao@localhost esbak]$ cd /tmp/esbak
[yeemiao@localhost esbak]$ cp -r ./* /home/yeemiao/single_elasticsearch/esbak


6.執行恢復
新的機器這個時候是沒有index的
[yeemiao@localhost esbak]$ curl -X GET 'http://192.168.1.134:9200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

執行恢復步驟
6.1 創建備份指定目錄
curl -H "Content-Type: application/json" -XPUT http://192.168.1.134:9200/_snapshot/esbackup -d'{
"type": "fs",
"settings": {
"location": "/home/yeemiao/single_elasticsearch/esbak"
}
}'

6.2 查看備份信息,這個時候備份信息已經注冊進來了
curl -X GET "http://192.168.1.134:9200/_snapshot/esbackup/_all?pretty"

6.3 執行恢復
curl -XPOST http://192.168.1.134:9200/_snapshot/esbackup/snapshot_20190815/_restore


7.驗證
[yeemiao@localhost esbak]$ curl -X GET 'http://192.168.1.134:9200/_cat/indices?v'
這里輸出查看到跟原來的主機結果一致

 

-- The End --


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM