elasticsearch startup warning could not lock JVM memory

  • 2021-07-07 07:25:04
  • OfStack

elasticsearch Startup Warning

Unable to lock JVM memory (ENOMEM). This can result in part of the JVM being swapped out. Increase RLIMIT_MEMLOCK (ulimit).

Limit of memory lock value (max locked memory)

This value only works for ordinary users, Does not work for superusers, This problem is caused by CAP_IPC_LOCK. linux is paged for memory, This means that when you don't need it, Data in physical memory will be swapped to swap area or disk. It will be swapped to physical memory when necessary. Locking data to physical memory prevents data swapping in/out. Locking memory is used for two reasons: 1) Because of programming needs, such as oracle and other software, it is necessary to lock the data into physical memory. 2) Mainly for security needs, such as user name and password, etc., which are exchanged to swap or disk, and there is the possibility of leakage, so 1 directly locks it into physical memory.

View the project progress limit, 17497 is pid

cat /proc/17497/limits

View System Restrictions ulimit-a


core file size     (blocks, -c) unlimited
data seg size      (kbytes, -d) unlimited
scheduling priority       (-e) 0
file size        (blocks, -f) unlimited
pending signals         (-i) 1032980
max locked memory    (kbytes, -l) 64
max memory size     (kbytes, -m) unlimited
open files           (-n) 600000
pipe size      (512 bytes, -p) 8
POSIX message queues   (bytes, -q) 819200
real-time priority       (-r) 0
stack size       (kbytes, -s) unlimited
cpu time        (seconds, -t) unlimited
max user processes       (-u) 600000
virtual memory     (kbytes, -v) unlimited
file locks           (-x) unlimited

vim/etc/security/limits. conf Add 2 rows, set to a larger value or unlimited

soft memlock unlimited hard memlock unlimited

Others can use ulimit to add custom restrictions (many options are not turned on by default), and you can restrict 1 different users


#
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority

Summarize


Related articles: