如何在 ubuntu 17.10 中限制 elasticsearch 的内存使用?

how to limit memory usage of elasticsearch in ubuntu 17.10?

我的 elasticsearch 服务消耗了大约 1 GB。

我的总内存是2GB。弹性搜索服务不断关闭。我想原因是因为内存消耗高。我怎样才能将使用量限制为 512 MB?

这是启动elasticsearch前的记忆

运行sudo service elasticsearch start后内存消耗猛增

感谢您的帮助!谢谢!

来自official doc

The default installation of Elasticsearch is configured with a 1 GB heap. For just about every deployment, this number is usually too small. If you are using the default heap values, your cluster is probably configured incorrectly.

所以你可以这样改

There are two ways to change the heap size in Elasticsearch. The easiest is to set an environment variable called ES_HEAP_SIZE. When the server process starts, it will read this environment variable and set the heap accordingly. As an example, you can set it via the command line as follows: export ES_HEAP_SIZE=512m

但不推荐。在可用 RAM 如此之少的情况下,您无法以最佳方式 运行 Elasticsearch。