Elasticsearch forcemerge 和 disc space 问题

Elasticserach forcemerge and disc space problem

我是 Elasticsearch 的新手,所以不要怪我太多。 情况是这样的,服务器几乎 运行 日志记录 space,剩余大约 400 MB。我不得不删除两年前的旧日志,但事实证明,它只是将它们标记为已删除,但实际上是在自动合并时在后台删除它们。我尝试清理的索引正积极用于向其写入日志,但为了释放磁盘 space,我决定 运行 a POST /logging/_forcemerge?only_expunge_deletes=true。通过GET _tasks?detailed=true&actions=*forcemerge,我看到任务是运行ning,但是2个小时没有任何反应。这个地方没有腾出,感觉不值得进行强制合并并听取论坛和网站上关于此程序的所有评论。

问题本身。

  1. 有什么方法可以知道强制合并将持续多长时间?
  2. 我关闭了写入该索引的服务器,据我所知,在强制合并期间写入索引是否不值得?
  3. 由于我使用参数only_expunge_deletes=true 只合并已删除文档的段,这会影响按索引搜索吗?
  4. 在这种情况下不会出现的最佳做法是什么?
  1. Is there any way I can find out how long force merge will last?

不,抱歉,强制合并不会报告有关其进度的任何信息。

  1. I turned off the servers that write to this index, as I understand it, is it not worth writing to the index during force merge?

强制合并是 generally only useful when you will never again write to an index。没有理由仅在合并期间停止写入索引,但相反,如果您希望继续写入索引,则根本不建议强制合并它。

  1. Since I used the parameter only_expunge_deletes=true to merge only segments with deleted documents, will this affect the search by index?

合并通常有利于搜索,这就是 Elasticsearch(实际上是 Lucene)在后台进行合并的原因。但是,强制合并可能会在将来中断通常的自动合并过程,这就是为什么建议不要在将来会写入的索引上执行此操作的原因。

  1. What is the best practice that would not arise in such situations?

鉴于您正在为日志编制索引,我认为您缺少的一个好习惯是使用 基于时间的索引:每隔一段时间(例如每月)开始一个新的索引名称包含日期(例如月份和年份)的索引。 Elasticsearch 允许您一次搜索多个索引(可能使用通配符或 alias). Then you can manage the lifecycle of these indices individually (there's even a feature for automatic index lifecycle management),其中包括在旧索引达到合适的年龄时删除它们。删除索引中文档的子集代价高昂且不一定节省 space,但删除整个索引成本低且立即释放 space。