ElasticSearch 快照 备份、恢复数据
生活随笔
收集整理的這篇文章主要介紹了
ElasticSearch 快照 备份、恢复数据
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- ElasticSearch 設置備份文件地址
- 注冊快照存儲庫
- 查看快照存儲庫保存結果
- 創建快照
- 異步創建
- 指定索引進行快照
- 查看全部快照
- 在服務器查看備份的數據
- 恢復數據
- 本機恢復
- 其他服務器恢復
- 常見問題
- 報錯 doesn't match any of the locations specified by path.repo because this setting is empty
ElasticSearch 設置備份文件地址
- 在elasticsearch.yml 新增
注冊快照存儲庫
ecopherebbs是我們定義的快照名,可以自定義
PUT _snapshot/ecopherebbs {"type": "fs","settings": {"location": "/home/es/snapshot"} }保存成功
查看快照存儲庫保存結果
GET _snapshot返回結果
{"ecopherebbs" : {"type" : "fs","settings" : {"compress": true,"location" : "/home/es/snapshot"}} }創建快照
異步創建
- 創建
- 查看狀態
處理中
{"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}}] }指定索引進行快照
PUT _snapshot/ecopherebbs/snapshot_20210630?wait_for_completion=true {"indices": "index1,index2","ignore_unavailable": true,"include_global_state": true }查看全部快照
GET _snapshot/ecopherebbs/_all?pretty在服務器查看備份的數據
每次執行快照都會生成一個 meta和一個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恢復數據
本機恢復
POST _snapshot/ecopherebbs/snapshot_20210631_02/_restore執行恢復要將之前的索引刪除,否則會報錯
- 或者在恢復時執行新索引名稱 官網描述
其他服務器恢復
注意:版本要相同,版本不同很有可能會導致失敗
path.repo: ["/home/es/snapshot"]
常見問題
報錯 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集群環境做災備和恢復時候,首先需要創建創建一個倉庫,并往倉庫中存放快照(每個快照中會區分不同的索引)。但是在創建倉庫的時候,要求倉庫的地址必須在每個集群環境中的elasticsearch.yml中進行配置
個人公眾號(大數據學習交流): hadoopwiki
總結
以上是生活随笔為你收集整理的ElasticSearch 快照 备份、恢复数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Flink 1.12 CDH 6.3 集
- 下一篇: zabbix server is not