解决磁盘空间不足的问题

解决磁盘空间不足的问题

本文介绍了使用Elasticsearch优化服务器操作:解决磁盘空间不足的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已编辑-根据@opster elasticsearch ninja的评论,我编辑了原始问题,以使其专注于ES的低磁盘水印错误.

EDITED - Based on comments of @opster elasticsearch ninja, I edited original question to keep it focused on low disk watermarks error for ES.

有关小型计算机上更常规的服务器优化,请参阅:在小型服务器(单节点)上调试Elasticsearch并进行调整

For more general server optimization on small machine, see:Debugging Elasticsearch and tuning on small server, single node

对于与调试ES故障有关的原始问题和注意事项的原始后续操作,还: https://chat.stackoverflow.com/rooms/213776/discussion-在opster-elasticsearch-ninja和user305883之间

For original follow up on the original question and considerations related to debugging ES failures, also:https://chat.stackoverflow.com/rooms/213776/discussion-between-opster-elasticsearch-ninja-and-user305883

问题:我注意到elasticsearch经常失败,需要手动重新启动服务器.

Problem : I noticed that elasticsearch is failing frequently, and need to restart the server manually.

此问题可能与以下问题有关:

This question may relate to: High disk watermark exceeded even when there is not much data in my index

我想更好地了解如果磁盘大小出现故障,elasticsearch会执行的操作,如何优化配置,然后才最终在系统出现故障时自动重新启动.

I want to have a better understanding about what elasticsearch will do if the disk size fails, how to optimise configuration and only afterwards eventually restart automatically when system fails.

您能帮助您了解如何阅读Elasticsearch期刊并做出相应的选择来解决问题,并建议最佳实践来调整小型服务器上的服务器操作吗?

Could you help in understanding how to read the elasticsearch journal and make a choice to fix the problems accordingly, suggesting best practices to tune server ops on a small server machine ?

我的首要任务是避免系统崩溃;可以降低性能,没有预算增加服务器大小.

My priority is not to have system crash; it is ok to have a bit less performance, no budget to increase server size.

硬件

我正在单个小型服务器(2GB)上运行elasticsearch,具有3个索引(存储大小分别为500mb,20mb和65mb)和几个GB的可用磁盘空间(固态):我想允许使用虚拟内存VS消耗RAM.

I am running elasticsearch on a single small server (2GB), have 3 index (500mb, 20mb and 65mb of store size) and several GB free on disk (state solid) : I would like to allow use virtual memory VS consuming RAM.

下面是我做的:

日记怎么说?

>探索与ES相关的失败.

journalctl | grep elasticsearch> explore failures related to ES.

    May 13 05:44:15 ubuntu systemd[1]: elasticsearch.service: Main process exited, code=killed, status=9/KILL
May 13 05:44:15 ubuntu systemd[1]: elasticsearch.service: Unit entered failed state.
May 13 05:44:15 ubuntu systemd[1]: elasticsearch.service: Failed with result 'signal'.

在这里我可以看到ES被杀.

Here I can see ES was killed.

编辑:我发现由于Java内存不足错误,请参见service elasticsearch status中的以下错误;读者可能还会发现运行有帮助:

EDITED : I have found due to out of memory error from java, see below error in service elasticsearch status ; readers may also find useful to run:

java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

检查当前的内存分配.

ES日志怎么说?

检查:

/var/log/elasticsearch


[2020-05-09T14:17:48,766][WARN ][o.e.c.r.a.DiskThresholdMonitor] [my_clustername-master] high disk watermark [90%] exceeded on [Ynm6YG-MQyevaDqT2n9OeA][awesome3-master][/var/lib/elasticsearch/nodes/0] free: 1.7gb[7.6%], shards will be relocated away from this node
[2020-05-09T14:17:48,766][INFO ][o.e.c.r.a.DiskThresholdMonitor] [my_clustername-master] rerouting shards: [high disk watermark exceeded on one or more nodes]

如果我只有一台服务器和一个实例在工作,分片将被移离该节点"会怎样?

what does "shards will be relocated away from this node" if I only have one server and one instance working ?

service elasticsearch status

 Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-05-09 13:47:02 UTC; 32min ago
     Docs: http://www.elastic.co
  Process: 22691 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCES
 Main PID: 22694 (java)
   CGroup: /system.slice/elasticsearch.service
           └─22694 /usr/bin/java -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+U

我的配置怎么说?

我使用的默认配置是/etc/elasticsearch/elasticsearch.yml.

I am using a default configuration of `/etc/elasticsearch/elasticsearch.yml´

并且没有为水印配置任何选项,例如 https://stackoverflow.com/a/52006486/305883

and don't have any options configured for watermark, like in https://stackoverflow.com/a/52006486/305883

我应该包括它们吗?他们会怎么做?

Should I include them ? What would they do ?

请注意,我未评论#bootstrap.memory_lock: true因为我只有2gb的内存.

Please note I have uncommented #bootstrap.memory_lock: truebecause I only have 2gb of ram.

即使在内存交换时Elasticsearch的性能也很差,我的首要任务是它不会失败,并且站点可以正常运行.

Even if elasticsearch will perform poorly if memory is swapping, my priority is that it does not fail, and the sites stays up and running.

在单节点计算机上运行-如何处理未分配的副本?

我知道不能在同一节点上分配副本.结果,在单个节点上具有副本是否有意义?如果主索引将失败,副本将可以挽救还是仍然不被使用?

I understood that replicas cannot be assigned on the same nodes.As a consequence, does it make sense to have replicas on a single node ?If a primary index will fail, replicas will come to rescue or will they be unused anyway ?

我想知道是否应该删除它们并留出空间,或者最好不要这么做.

I wonder if I should delete them and make space, or better not to.

推荐答案

请阅读详细说明了opster的指南关于什么是低磁盘水印以及如何临时固定地对其进行修复.

Please read the detailed explanation of opster's guide on what is low disk watermark and how to temp and permamnent fix it.

您的问题的说明:

如果我只有一台服务器和一个实例,那么碎片将被移离该节点"

Shards will be relocated away from this node" if I only have one server and one instance working?

在您的情况下,由于您只有一个数据节点,因此即使释放后,同一数据节点上的所有索引也会进入读取模式 空格,除非您明确命中 opster的指南中提到的API.

In your case, as you have just one data node, all the indices on the same data node will be put into reading mode and even if you free up space it wouldn't come in writing mode until you explicitly hit the API mentioned in opster's guide.

在单个节点上最好禁用副本,因为Elasticsearch不会将分片的副本分配给同一数据节点.因此,在单个节点Elasticasearch群集上具有副本是没有意义的,这样做将不必要地将您的索引和群集运行状况标记为黄色(缺少副本).

On a single node it would be better to disable replica as Elasticsearch would not allocate replica of a shard to the same data node. So it doesn't make sense to have replicas on a single node Elasticasearch cluster and doing that will unnecessary mark your index and cluster health to yellow(missing replica).

这篇关于使用Elasticsearch优化服务器操作:解决磁盘空间不足的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 06:40