打开文件/etc/elasticsearch/jvm.options,找到
-Xms和-Xmx
如:

-Xms2g
-Xmx2g

表示目前elasticsearch允许最大使用2g内存。
修改之后,执行重启elasticsearch

service elasticsearch restart