ElasticSearch 快照 备份、恢复数据
生活随笔
收集整理的這篇文章主要介紹了
ElasticSearch 快照 备份、恢复数据
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- ElasticSearch 設(shè)置備份文件地址
- 注冊(cè)快照存儲(chǔ)庫(kù)
- 查看快照存儲(chǔ)庫(kù)保存結(jié)果
- 創(chuàng)建快照
- 異步創(chuàng)建
- 指定索引進(jìn)行快照
- 查看全部快照
- 在服務(wù)器查看備份的數(shù)據(jù)
- 恢復(fù)數(shù)據(jù)
- 本機(jī)恢復(fù)
- 其他服務(wù)器恢復(fù)
- 常見(jiàn)問(wèn)題
- 報(bào)錯(cuò) doesn't match any of the locations specified by path.repo because this setting is empty
ElasticSearch 設(shè)置備份文件地址
- 在elasticsearch.yml 新增
注冊(cè)快照存儲(chǔ)庫(kù)
ecopherebbs是我們定義的快照名,可以自定義
PUT _snapshot/ecopherebbs {"type": "fs","settings": {"location": "/home/es/snapshot"} }保存成功
查看快照存儲(chǔ)庫(kù)保存結(jié)果
GET _snapshot返回結(jié)果
{"ecopherebbs" : {"type" : "fs","settings" : {"compress": true,"location" : "/home/es/snapshot"}} }創(chuàng)建快照
異步創(chuàng)建
- 創(chuàng)建
- 查看狀態(tài)
處理中
{"snapshots" : [{"snapshot" : "snapshot_20210631","uuid" : "PTBkWV-pQ8CQ7l4RNxISfA","version_id" : 7090399,"version" : "7.9.3","indices" : ["t_e_s_t___2_0_2_1_0_4_2_1_0_9_2_9_index","test0627","test110",".kibana-event-log-7.9.3-000001","fang_fa_index","filebeat-7.9.3-2021.06.29-000001","gateway_requests","my_index","ilm-history-2-000003",".kibana-event-log-7.9.3-000002",".kibana_1"],"data_streams" : [ ],"include_global_state" : true,"state" : "IN_PROGRESS","start_time" : "2021-06-30T05:26:10.530Z","start_time_in_millis" : 1625030770530,"end_time" : "1970-01-01T00:00:00.000Z","end_time_in_millis" : 0,"duration_in_millis" : 0,"failures" : [ ],"shards" : {"total" : 0,"failed" : 0,"successful" : 0}}] }處理完成
{"snapshots" : [{"snapshot" : "snapshot_20210631","uuid" : "PTBkWV-pQ8CQ7l4RNxISfA","version_id" : 7090399,"version" : "7.9.3","indices" : ["t_e_s_t___2_0_2_1_0_4_2_1_0_9_2_9_index","test0627","test110",".kibana-event-log-7.9.3-000001","fang_fa_index","filebeat-7.9.3-2021.06.29-000001","gateway_requests","my_index","ilm-history-2-000003",".kibana-event-log-7.9.3-000002",".kibana_1"],"data_streams" : [ ],"include_global_state" : true,"state" : "SUCCESS","start_time" : "2021-06-30T05:26:10.530Z","start_time_in_millis" : 1625030770530,"end_time" : "2021-06-30T05:26:16.937Z","end_time_in_millis" : 1625030776937,"duration_in_millis" : 6407,"failures" : [ ],"shards" : {"total" : 200,"failed" : 0,"successful" : 200}}] }指定索引進(jìn)行快照
PUT _snapshot/ecopherebbs/snapshot_20210630?wait_for_completion=true {"indices": "index1,index2","ignore_unavailable": true,"include_global_state": true }查看全部快照
GET _snapshot/ecopherebbs/_all?pretty在服務(wù)器查看備份的數(shù)據(jù)
每次執(zhí)行快照都會(huì)生成一個(gè) meta和一個(gè)snap文件
[es@test12 snapshot]$ ls -lrt 總用量 1404 drwxrwxr-x. 62 es es 4096 6月 30 13:23 indices -rw-rw-r--. 1 es es 460329 6月 30 13:24 meta--WCM58RpQNm5bEywCjO_cg.dat -rw-rw-r--. 1 es es 1596 6月 30 13:24 snap--WCM58RpQNm5bEywCjO_cg.dat -rw-rw-r--. 1 es es 1596 6月 30 13:26 snap-PTBkWV-pQ8CQ7l4RNxISfA.dat -rw-rw-r--. 1 es es 460329 6月 30 13:26 meta-PTBkWV-pQ8CQ7l4RNxISfA.dat -rw-rw-r--. 1 es es 302 6月 30 13:52 snap-N3zRMDnDTEqoiShEwjKosA.dat -rw-rw-r--. 1 es es 460329 6月 30 13:52 meta-N3zRMDnDTEqoiShEwjKosA.dat -rw-rw-r--. 1 es es 24990 6月 30 13:52 index-2 -rw-rw-r--. 1 es es 8 6月 30 13:52 index.latest恢復(fù)數(shù)據(jù)
本機(jī)恢復(fù)
POST _snapshot/ecopherebbs/snapshot_20210631_02/_restore執(zhí)行恢復(fù)要將之前的索引刪除,否則會(huì)報(bào)錯(cuò)
- 或者在恢復(fù)時(shí)執(zhí)行新索引名稱 官網(wǎng)描述
其他服務(wù)器恢復(fù)
注意:版本要相同,版本不同很有可能會(huì)導(dǎo)致失敗
path.repo: ["/home/es/snapshot"]
常見(jiàn)問(wèn)題
報(bào)錯(cuò) doesn’t match any of the locations specified by path.repo because this setting is empty
{"error" : {"root_cause" : [{"type" : "repository_exception","reason" : "[ecopherebbs] location [/home/es/snapshot] doesn't match any of the locations specified by path.repo because this setting is empty"}],"type" : "repository_exception","reason" : "[ecopherebbs] failed to create repository","caused_by" : {"type" : "repository_exception","reason" : "[ecopherebbs] location [/home/es/snapshot] doesn't match any of the locations specified by path.repo because this setting is empty"}},"status" : 500 }- 解決方法:
在為es集群環(huán)境做災(zāi)備和恢復(fù)時(shí)候,首先需要?jiǎng)?chuàng)建創(chuàng)建一個(gè)倉(cāng)庫(kù),并往倉(cāng)庫(kù)中存放快照(每個(gè)快照中會(huì)區(qū)分不同的索引)。但是在創(chuàng)建倉(cāng)庫(kù)的時(shí)候,要求倉(cāng)庫(kù)的地址必須在每個(gè)集群環(huán)境中的elasticsearch.yml中進(jìn)行配置
個(gè)人公眾號(hào)(大數(shù)據(jù)學(xué)習(xí)交流): hadoopwiki
總結(jié)
以上是生活随笔為你收集整理的ElasticSearch 快照 备份、恢复数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Flink 1.12 CDH 6.3 集
- 下一篇: Windows 中_T和L