我有许多(10+)个Elasticsearch集群,并且该集群用于不同目的(存储日志,存储一些业务和分析数据)
因此,例如,我有一个用于某些业务数据(用户在电子商务网站中购物车)使用的3节点elasticsearch集群,并且我每天都拍摄快照
并且该群集将快照制作为NFS共享,我的管理员告诉我,我必须清除快照存储库中的最后10个快照以释放磁盘空间。
例如,某人(或我)不小心启动了curl -XDELETE/*
,它删除了集群中的所有索引,并且我必须还原此处的所有业务数据,并且从最后10天开始只有10张快照,我是否可以还原所有数据?还是仅从上次快照日期恢复数据?因为在文档中说 Snapshots are incremental: each snapshot only stores data that is not part of an earlier snapshot
因此,例如,我网站上的客户Joe在2020年1月9日向购物车中添加了一些东西,然后在2020年9月15日,我从群集中删除了所有数据,而我在快照存储库中的最后一个快照是/ 03/09/2020因此如果我从该快照还原,该快照将包含旧数据还是不包含旧数据?
对不起,我的英语不好
最佳答案
要了解这一点,一个有趣的测试是执行以下过程:
您认为第一个文件不见了吗?让我们找出...这是重现上述过程的所有步骤:
# 1. create an index
PUT test
# 2. index one document
PUT test/_doc/1
{
"id": 1
}
# 3. create a first snapshot A
PUT /_snapshot/my-snapshots/snapshot_a?wait_for_completion=true
{
"indices": "test",
"ignore_unavailable": true,
"include_global_state": false
}
# 4. index a second document
PUT test/_doc/2
{
"id": 2
}
# 5. create a second snapshot B
PUT /_snapshot/my-snapshots/snapshot_b?wait_for_completion=true
{
"indices": "test",
"ignore_unavailable": true,
"include_global_state": false
}
# 6. delete the first snapshot A
DELETE /_snapshot/my-snapshots/snapshot_a
# 7. delete the index
DELETE test
# 8. restore the snapshot B
POST /_snapshot/found-snapshots/snapshot_b/_restore
# 9. And now check the content of the index
GET test/_search
=>
"hits" : [
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"id" : 1
}
},
{
"_index" : "test",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"id" : 2
}
}
]
因此,最重要的是,较旧的文档仍包含在较新的快照中,删除旧快照并不意味着删除旧文档。快照包含快照创建时存在的所有分片段文件的精确副本。随着时间的流逝,较小的段文件将获得merged into bigger ones。当下一个快照发生时,它将复制较新的较大段文件,而较旧的快照仍将包含较旧的较小段文件。
但是,这并不意味着仅保留最新快照并认为所有数据都在其中始终是安全的,但是如果您每天进行快照,我认为仅保留最后10个快照并期望所有快照都是安全的。数据在那里。
关于elasticsearch - Elasticsearch快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64498925/