设置elasticsearch的java heap大小:
The default installation of Elasticsearch is configured with a 1 GB heap.
There are two ways to change the heap size in Elasticsearch.
1、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=10g
2、you can pass in the heap size via a command-line argument when starting the process, if that is easier for your setup:
-Xmx(maximun allowed memory for the process)
-Xms(minimun allowed memory for the process)
还有另一种方式,可以直接修改es的启动脚本,修改默认的JAVA_OPTS设置
[es@master001 es-node01]$ vi bin/elasticsearch.in.sh
if [ "x$ES_MIN_MEM" = "x" ]; then
ES_MIN_MEM=256m #-Xms
fi
if [ "x$ES_MAX_MEM" = "x" ]; then
ES_MAX_MEM=1g # -Xmx
fi
if [ "x$ES_HEAP_SIZE" != "x" ]; then
ES_MIN_MEM=$ES_HEAP_SIZE
ES_MAX_MEM=$ES_HEAP_SIZE
fi