真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

elasticsearch數(shù)據(jù)備份恢復(fù)

本文主要介紹elasticsearch集群數(shù)據(jù)備份及恢復(fù),利用共享文件系統(tǒng),通過快照方式備份。

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),克山企業(yè)網(wǎng)站建設(shè),克山品牌網(wǎng)站建設(shè),網(wǎng)站定制,克山網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,克山網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

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

一、配置修改

1.配置文件必須添加如下參數(shù)

path.repo:  /mnt/backups/es_mybak

二、數(shù)據(jù)備份

1.創(chuàng)建備份倉庫

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 。

我們指定倉庫的類型應(yīng)該是一個共享文件系統(tǒng),這里采用nfs。

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

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

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'
查看快照的詳細(xì)信息,可以看到每個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
      }
    }
  ]
}

三、.部分索引數(shù)據(jù)恢復(fù)

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.根據(jù)snapshot_els_student_hnr05快照恢復(fù)索引

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已經(jīng)恢復(fù)回來

四、數(shù)據(jù)完全恢復(fù)

1.關(guān)閉所有節(jié)點,刪除數(shù)據(jù)目錄下的所有數(shù)據(jù),重新啟動集群

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

2.重新啟動集群

elasticsearch數(shù)據(jù)備份恢復(fù)

3.創(chuàng)建備份倉庫

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.恢復(fù)數(shù)據(jù)

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
至此所有索引已經(jīng)完全恢復(fù)

elasticsearch數(shù)據(jù)備份恢復(fù)

五、從全部索引快照中恢復(fù)單個索引

1.刪除索引els_student_hnr05

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

2.恢復(fù)被刪除的索引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'

文章名稱:elasticsearch數(shù)據(jù)備份恢復(fù)
網(wǎng)頁URL:http://weahome.cn/article/jgeech.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部