使用 elasticsearch 优化服务器操作 : addressing low disk watermarks

optimise server operations with elasticsearch : addressing low disk watermarks

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

有关小型机器上更通用的服务器优化,请参阅: Debugging Elasticsearch and tuning on small server, single node

对于与调试 ES 故障相关的原始问题和注意事项的原始跟进,还有: https://chat.whosebug.com/rooms/213776/discussion-between-opster-elasticsearch-ninja-and-user305883


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

这个问题可能涉及:

我想更好地了解如果磁盘大小失败,elasticsearch 会做什么,如何优化配置,然后最终在系统失败时自动重启。

您能否帮助理解如何阅读 elasticsearch 日志并做出相应的解决问题的选择,建议在小型服务器计算机上调整服务器操作的最佳实践?

我的首要任务是不让系统崩溃;性能稍差一点没关系,没有增加服务器大小的预算。

硬件

我 运行 在一个小型服务器 (2GB) 上使用 elasticsearch,有 3 个索引(500mb、20mb 和 65mb 的存储大小)和几个 GB 的磁盘空闲空间(状态稳定):我想要允许使用虚拟内存 VS 消耗 RAM。

低于我所做的:


期刊怎么说的?

journalctl | grep elasticsearch> 探索与 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被杀了。

EDITED :我发现由于 java 中的内存不足错误,请参阅 service elasticsearch status 中的以下错误;读者可能还会发现对 运行:

有用
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]

如果我只有一台服务器和一个实例在工作,"shards will be relocated away from this node" 会怎样?

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´

并且没有为水印配置任何选项,例如

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

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

即使 elasticsearch 在内存交换时性能不佳,我的首要任务是它不会失败,并且站点保持正常运行 运行ning。

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

我了解不能在相同节点上分配副本。 因此,在单个节点上拥有副本是否有意义? 如果主索引失败,副本会来救援,还是会一直闲置?

我想知道我是否应该删除它们并制作 space,或者最好不要。

您问题的解释:

如果我只有一台服务器和一个实例在工作,碎片将被重新定位远离这个节点?

Elasticsearch considers the available disk space before deciding whether to allocate new shards, relocate shards away or put all indices on reading mode based on a different threshold of this error, Reason being Elasticsearch indices consists of different shards which are persisted on data nodes and low disk space can cause the above issues.

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 集群上拥有副本是没有意义的,这样做会不必要地将您的索引和集群健康状况标记为黄色(缺少副本)。