使用 Easysearch 还原 Elasticsearch 快照数据

打印 上一主题 下一主题

主题 541|帖子 541|积分 1623

本文主要验证 Elasticsearch 快照在 Easysearch 中进行数据恢复。
准备测试数据

索引


别名


模版


生命周期策略


创建快照
  1. PUT /_snapshot/my_backup
  2. {
  3.   "type": "fs",
  4.   "settings": {
  5.     "location": "/infini/test/es_backup"
  6.   }
  7. }
  8. PUT /_snapshot/my_backup/snapshot_1
  9. {
  10.   "indices": "*",
  11.   "ignore_unavailable": false,
  12.   "include_global_state": false
  13. }
  14. GET /_snapshot/my_backup/snapshot_1
复制代码

  • ignore_unavailable:如果 indices 列表中的索引不存在,则是否忽略该索引而不是使快照失败。默认值为 false 。
  • include_global_state:是否在快照中包含集群状态(包括索引模版、生命周期配置、持久化配置等)。默认值为 true ,建议设为 false。
恢复快照
  1. POST /_snapshot/my_backup/snapshot_1/_restore
  2. {
  3.   "indices": "*",
  4.   "ignore_unavailable": false,
  5.   "include_global_state": false,
  6.   "include_aliases": true,
  7.   "ignore_index_settings": [
  8.     "index.lifecycle.indexing_complete"
  9.   ]
  10. }
复制代码

  • ignore_unavailable:如果 indices 列表中的索引不存在,则是否忽略该索引而不是使还原操作失败。默认值为 false 。
  • include_global_state:是否还原群集状态。默认值为 false 。
  • include_aliases:是否恢复别名及其关联索引。默认值为 true 。
  • index.lifecycle.indexing_complete 配置不支持,忽略掉。
数据验证

索引


通过 gateway 进行数据比对
  1. path.data: data
  2. path.logs: log
  3. #show progress bar
  4. #progress_bar.enabled: true
  5. elasticsearch:
  6.   - name: source
  7.     enabled: true
  8.     endpoints:
  9.       - http://192.168.3.185:29200
  10.   - name: target
  11.     enabled: true
  12.     endpoints:
  13.       - https://192.168.3.185:9205
  14.     basic_auth:
  15.       username: admin
  16.       password: admin
  17. pipeline:
  18.   - name: index_diff_service
  19.     auto_start: true
  20.     processor:
  21.       - dag:
  22.           mode: wait_all
  23.           parallel:
  24.             - dump_hash: #dump es1's doc
  25.                 sort_document_fields: true
  26.                 indices: ".infini_activities-000004"   ##需要比对的索引名
  27.                 scroll_time: "10m"
  28.                 elasticsearch: "source"
  29.                 #              query_string: "_id:c8es70pu46lgfdgmja9g-1646117763293610802-2"
  30.                 #              fields: "doc_hash"
  31.                 output_queue: "source_docs"
  32.                 batch_size: 5000
  33.                 slice_size: 1
  34.             #              hash_func: "xxhash64"
  35.             - dump_hash: #dump es2's doc
  36.                 indices: ".infini_activities-000004"
  37.                 scroll_time: "10m"
  38.                 #              fields: "doc_hash"
  39.                 #              query_string: "_id:c8es70pu46lgfdgmja9g-1646117763293610802-2"
  40.                 batch_size: 5000
  41.                 slice_size: 1
  42.                 #              hash_func: "xxhash64"
  43.                 elasticsearch: "target"
  44.                 output_queue: "target_docs"
  45.           end:
  46.             - index_diff:
  47.                 diff_queue: "diff_result"
  48.                 buffer_size: 10
  49.                 text_report: true #如果要存 es,这个开关关闭,开启 pipeline 的 diff_result_ingest 任务
  50.                 source_queue: "source_docs"
  51.                 target_queue: "target_docs"
  52. #pipeline:
  53. #  - name: diff_result_ingest
  54. #    processor:
  55. #      - json_indexing:
  56. #          index_name: "diff_result"
  57. #          elasticsearch: "source"
  58. #          input_queue: "diff_result"
复制代码
./gateway-linux-amd64 -config data_check.yml

别名


模版
  1. PUT _template/.infini_activities-rollover
  2. {
  3.   "order": 100000,
  4.   "index_patterns": [
  5.     ".infini_activities*"
  6.   ],
  7.   "settings": {
  8.     "index": {
  9.       "format": "7",
  10.       "lifecycle": {
  11.         "name": "ilm_.infini_metrics-30days-retention",
  12.         "rollover_alias": ".infini_activities"
  13.       },
  14.       "codec": "best_compression",
  15.       "number_of_shards": "1",
  16.       "translog": {
  17.         "durability": "async"
  18.       }
  19.     }
  20.   },
  21.   "mappings": {
  22.     "dynamic_templates": [
  23.       {
  24.         "strings": {
  25.           "mapping": {
  26.             "ignore_above": 256,
  27.             "type": "keyword"
  28.           },
  29.           "match_mapping_type": "string"
  30.         }
  31.       }
  32.     ]
  33.   },
  34.   "aliases": {}
  35. }
  36. PUT _template/.infini
  37. {
  38.   "order": 0,
  39.   "index_patterns": [
  40.     ".infini_*"
  41.   ],
  42.   "settings": {
  43.     "index": {
  44.       "max_result_window": "10000000",
  45.       "mapping": {
  46.         "total_fields": {
  47.           "limit": "20000"
  48.         }
  49.       },
  50.       "analysis": {
  51.         "analyzer": {
  52.           "suggest_text_search": {
  53.             "filter": [
  54.               "word_delimiter"
  55.             ],
  56.             "tokenizer": "classic"
  57.           }
  58.         }
  59.       },
  60.       "number_of_shards": "1"
  61.     }
  62.   },
  63.   "mappings": {
  64.     "dynamic_templates": [
  65.       {
  66.         "strings": {
  67.           "mapping": {
  68.             "ignore_above": 256,
  69.             "type": "keyword"
  70.           },
  71.           "match_mapping_type": "string"
  72.         }
  73.       }
  74.     ]
  75.   },
  76.   "aliases": {}
  77. }
复制代码
生命周期策略
  1. PUT _ilm/policy/ilm_.infini_metrics-30days-retention
  2. {
  3.   "policy": {
  4.     "phases": {
  5.       "hot": {
  6.         "min_age": "0ms",
  7.         "actions": {
  8.           "rollover": {
  9.             "max_size": "50gb",
  10.             "max_age": "30d"
  11.           },
  12.           "set_priority": {
  13.             "priority": 100
  14.           }
  15.         }
  16.       },
  17.       "delete": {
  18.         "min_age": "30d",
  19.         "actions": {
  20.           "delete": {
  21.           }
  22.         }
  23.       }
  24.     }
  25.   }
  26. }
复制代码
注:不支持 "delete_searchable_snapshot": true 配置
测试结果

源集群(Elasticsearch)目标集群(Easysearch)测试结果7.10.21.0.0索引文档一致,别名恢复成功7.10.11.0.0索引文档一致,别名恢复成功7.10.01.0.0索引文档一致,别名恢复成功7.9.21.0.0索引文档一致,别名恢复成功7.9.01.0.0索引文档一致,别名恢复成功7.8.11.0.0索引文档一致,别名恢复成功7.5.21.0.0索引文档一致,别名恢复成功6.8.121.0.0索引文档一致,别名恢复成功6.5.41.0.0索引文档一致,别名恢复成功关于 Easysearch


INFINI Easysearch 是一个分布式的近实时搜索与分析引擎,核心引擎基于开源的 Apache Lucene。 Easysearch 衍生自基于开源协议 Apache 2.0 的 Elasticsearch 7.10 版本。 Easysearch 的目标是提供一个轻量级的 Elasticsearch 可替代版本,并继续完善和支持更多的企业级功能。 与 Elasticsearch 相比,Easysearch 更关注在搜索业务场景的优化和继续保持其产品的简洁与易用性。
详情参见:官方文档

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

小秦哥

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表