Virtual memory
sysctl -w vm.max_map_count=262144
Disable swap
Usually Elasticsearch is the only service running on a box, and its memory usage is controlled by theES_HEAP_SIZE
environment variable. There should be no need to have swap enabled.
On Linux systems, you can disable swap temporarily by running: sudo swapoff -a
. To disable it permanently, you will need to edit the /etc/fstab
file and comment out any lines that contain the word swap
.
Configure swappiness
vm.swappiness
is set to 0
mlockall
config/elasticsearch.yml
file:
bootstrap.mlockall:true
这是让 JVM 启动的时候就 锁定 heap 内存。
参考: