elasticsearch數據備份恢復-創新互聯

本文主要介紹elasticsearch集群數據備份及恢復,利用共享文件系統,通過快照方式備份。

創新互聯從2013年創立,是專業互聯網技術服務公司,擁有項目成都網站設計、網站制作網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元西盟做網站,已為上家服務,為西盟各地企業和個人服務,聯系電話:18980820575

集群的部署參考:http://hnr520.blog.51cto.com/4484939/1876467

一、配置修改

1.配置文件必須添加如下參數

path.repo:  /mnt/backups/es_mybak

二、數據備份

1.創建備份倉庫

curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup' -d '{   "type": "fs", "settings": {     "location": "/mnt/backups/es_mybak"     } }' [root@node1 local]# curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup' -d '{ > "type": "fs", > "settings": { >     "location": "/mnt/backups/es_mybak" > } > }' {"acknowledged":true}

給我們的倉庫取一個名字,在本例它叫 EsBackup 。

我們指定倉庫的類型應該是一個共享文件系統,這里采用nfs。

最后,我們提供一個已掛載的設備(/mnt/backups/es_mybak )作為目的地址。

注意:共享文件系統路徑必須確保集群所有節點都可以訪問到。

2.查詢備份倉庫

[root@node1 local]# curl -XGET 'http://192.168.115.11:9200/_snapshot?pretty' {   "EsBackup" : {     "type" : "fs",     "settings" : {       "location" : "/mnt/backups/es_mybak"     }   } }

3.備份所有索引

curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_all' [root@node1 local]# curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_all' {"accepted":true}

4.查看備份快照

curl -XGET 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_all?pretty' [root@node1 elasticsearch6]# curl -XGET 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_*?pretty'  {   "snapshots" : [     {       "snapshot" : "snapshot_all",       "uuid" : "MRTYocxBT4qgwtpu_6jdpg",       "version_id" : 5000199,       "version" : "5.0.1",       "indices" : [         "els_student_hnr05",         "hnrtest",         "els_student_hnr03",         "els_student",         "els_student_hnr02",         "els_student_hnr04",         "els_python01",         "els_student_hnr01"       ],       "state" : "SUCCESS",       "start_time" : "2017-05-17T10:00:46.860Z",       "start_time_in_millis" : 1495015246860,       "end_time" : "2017-05-17T10:00:54.209Z",       "end_time_in_millis" : 1495015254209,       "duration_in_millis" : 7349,       "failures" : [ ],       "shards" : {         "total" : 40,         "failed" : 0,         "successful" : 40       }     }   ] }

5.備份部分索引

curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05' -d '{ "indices": "els_student_hnr05" }' [root@node1 elasticsearch6]# curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05' -d '{ "indices": "els_student_hnr05" }' {"accepted":true}

6.查看備份快照

curl -XGET 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05?pretty' 查看快照的詳細信息,可以看到每個shard的信息 curl -XGET 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05/_status?pretty' [root@node1 elasticsearch6]# curl -XGET 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05?pretty'    {   "snapshots" : [     {       "snapshot" : "snapshot_els_student_hnr05",       "uuid" : "hsSkWa63Ss6MJjh0Eo4arA",       "version_id" : 5000199,       "version" : "5.0.1",       "indices" : [         "els_student_hnr05"       ],       "state" : "SUCCESS",       "start_time" : "2017-05-18T00:58:35.699Z",       "start_time_in_millis" : 1495069115699,       "end_time" : "2017-05-18T00:58:36.396Z",       "end_time_in_millis" : 1495069116396,       "duration_in_millis" : 697,       "failures" : [ ],       "shards" : {         "total" : 5,         "failed" : 0,         "successful" : 5       }     }   ] }

三、.部分索引數據恢復

1.查詢索引

curl -XGET '192.168.115.11:9200/_cat/indices?v' health status index             uuid                   pri rep docs.count docs.deleted store.size pri.store.size green  open   els_student_hnr05 mkvmTguZS4m1wGKbB8TOEw   5   1         99            0    124.7kb         62.3kb green  open   hnrtest           Y-bjuEPLQTGGP88EafDlyg   5   1          0            0      1.5kb           795b green  open   els_student_hnr03 _UHB6P-fRfucH7lEyE-C7g   5   1         99            0    146.7kb         73.3kb green  open   els_student       JC69IBEjTji8jU6bxCDE3A   5   1        999            0    495.9kb        247.9kb green  open   els_student_hnr02 k-aLl7tzRUyRfwJs8O0-kA   5   1         99            0    109.8kb         54.9kb green  open   els_student_hnr04 zAkj7GvfQ-CqmuFMJUTSuA   5   1         99            0    162.8kb         81.4kb green  open   els_python01      wmdREADVQmCX773_JDL46Q   5   1          0            0      1.5kb           795b green  open   els_student_hnr01 BJlcIp7mS0ii9nDYj8UDyQ   5   1        100            0    109.2kb         54.6kb

2.刪除索引els_student_hnr05

[root@node1 elasticsearch6]# curl -XDELETE 'http://192.168.115.11:9200/els_student_hnr05' {"acknowledged":true}

3.根據snapshot_els_student_hnr05快照恢復索引

curl -XPOST 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05/_restore' [root@node1 elasticsearch6]# curl -XPOST 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05/_restore' {"accepted":true}

4.再次查看索引

[root@node1 elasticsearch6]# curl -XGET '192.168.115.11:9200/_cat/indices?v' health status index             uuid                   pri rep docs.count docs.deleted store.size pri.store.size green  open   hnrtest           Y-bjuEPLQTGGP88EafDlyg   5   1          0            0      1.5kb           795b green  open   els_student_hnr05 S3AsHa4dRtuXXZ3uIDGvuQ   5   1         99            0    124.7kb         62.3kb

被刪除的索引els_student_hnr05已經恢復回來

四、數據完全恢復

1.關閉所有節點,刪除數據目錄下的所有數據,重新啟動集群

kill -9 $(ps -ef | grep -v grep | grep elasticsearch | awk '{print $2}')

2.重新啟動集群

elasticsearch數據備份恢復

3.創建備份倉庫

curl -XPUT 'http://192.168.115.11:9200/_snapshot/EsBackup' -d '{ "type": "fs", "settings": {     "location": "/mnt/backups/es_mybak"     } }'

4.查看備份快照

curl -XGET 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_*?pretty' {   "snapshots" : [     {       "snapshot" : "snapshot_all",       "uuid" : "MRTYocxBT4qgwtpu_6jdpg",       "version_id" : 5000199,       "version" : "5.0.1",       "indices" : [         "els_student_hnr05",         "hnrtest",         "els_student_hnr03",         "els_student",         "els_student_hnr02",         "els_student_hnr04",         "els_python01",         "els_student_hnr01"       ],       "state" : "SUCCESS",       "start_time" : "2017-05-17T10:00:46.860Z",       "start_time_in_millis" : 1495015246860,       "end_time" : "2017-05-17T10:00:54.209Z",       "end_time_in_millis" : 1495015254209,       "duration_in_millis" : 7349,       "failures" : [ ],       "shards" : {         "total" : 40,         "failed" : 0,         "successful" : 40       }     },     {       "snapshot" : "snapshot_els_student_hnr05",       "uuid" : "hsSkWa63Ss6MJjh0Eo4arA",       "version_id" : 5000199,       "version" : "5.0.1",       "indices" : [         "els_student_hnr05"       ],       "state" : "SUCCESS",       "start_time" : "2017-05-18T00:58:35.699Z",       "start_time_in_millis" : 1495069115699,       "end_time" : "2017-05-18T00:58:36.396Z",       "end_time_in_millis" : 1495069116396,       "duration_in_millis" : 697,       "failures" : [ ],       "shards" : {         "total" : 5,         "failed" : 0,         "successful" : 5       }     }   ] }

5.恢復數據

curl -XPOST 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_all/_restore'

6.查詢索引

[root@node1 elasticsearch6]# curl -XGET '192.168.115.11:9200/_cat/indices?v' health status index             uuid                   pri rep docs.count docs.deleted store.size pri.store.size green  open   hnrtest           LNkwevA2Sr2Jgue1oLRIGA   5   1          0            0      1.5kb           795b green  open   els_student       6aE8M7KMRN2EdievhDBXcw   5   1        999            0    495.9kb        247.9kb green  open   els_student_hnr04 8hXeVjXYRhS5POdy3hnMuQ   5   1         99            0    162.8kb         81.4kb green  open   els_student_hnr01 afVLqgxpTqii6pNObLC2sA   5   1        100            0    109.2kb         54.6kb green  open   els_student_hnr05 jzHPY_TlSEm-ZEXWz0sz4Q   5   1         99            0    124.7kb         62.3kb green  open   els_student_hnr02 f3hqeM1pQkWttZifnCCQDQ   5   1         99            0    109.8kb         54.9kb green  open   els_python01      4_vFwhn0RCi3SZbz2bORCw   5   1          0            0      1.5kb           795b green  open   els_student_hnr03 esFyZMwwTaeLf7YrKxyYjQ   5   1         99            0    146.7kb         73.3kb 至此所有索引已經完全恢復

elasticsearch數據備份恢復

五、從全部索引快照中恢復單個索引

1.刪除索引els_student_hnr05

curl -XDELETE 'http://192.168.115.11:9200/els_student_hnr05'

2.恢復被刪除的索引els_student_hnr05

curl -XPOST 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_all/_restore' -d '{     "indices": "els_student_hnr05",      "rename_replacement": "restored_index_$1" }'

六、刪除快照

curl -XDELETE 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_els_student_hnr05' curl -XDELETE 'http://192.168.115.11:9200/_snapshot/EsBackup/snapshot_all'

另外有需要云服務器可以了解下創新互聯cdcxhl.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

新聞標題:elasticsearch數據備份恢復-創新互聯
轉載源于:http://m.kartarina.com/article48/cdccep.html

成都網站建設公司_創新互聯,為您提供品牌網站制作網頁設計公司響應式網站網站維護自適應網站網站排名

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站優化排名
主站蜘蛛池模板: 无码毛片视频一区二区本码| AAA级久久久精品无码片| 久久无码无码久久综合综合| 中文字幕精品无码一区二区| 熟妇人妻中文字幕无码老熟妇| 亚洲av无码电影网| 成人无码精品一区二区三区| 久久久久久亚洲av成人无码国产| 精品无码综合一区二区三区| 亚洲成a人片在线观看无码专区 | 无码熟妇人妻av| 成人无码一区二区三区| 亚洲中文无码卡通动漫野外 | a级毛片无码免费真人久久 | 亚洲成a人片在线观看天堂无码| 亚洲精品无码日韩国产不卡?V| 国产成人无码AV麻豆| 熟妇无码乱子成人精品| 国产精品无码av在线播放| 无码国模国产在线观看| 亚洲熟妇无码八V在线播放| 97无码人妻福利免费公开在线视频 | 亚洲AV无码片一区二区三区| 无码专区狠狠躁躁天天躁| 精品久久久无码中文字幕| 国产福利无码一区在线| 亚洲午夜无码久久| 无码国产精品一区二区免费| 亚洲爆乳精品无码一区二区三区| 无码AV一区二区三区无码| 无码色偷偷亚洲国内自拍| 无码人妻丰满熟妇区毛片18| 日韩放荡少妇无码视频| 亚无码乱人伦一区二区| 久久亚洲精品无码av| 狠狠久久精品中文字幕无码| 岛国av无码免费无禁网站| 夜夜精品无码一区二区三区| 免费人妻无码不卡中文字幕18禁| 国产成人无码免费视频97| 潮喷无码正在播放|