elasticsearch启动警告无法锁定JVM内存

时间:2021-08-25 19:14:13

elasticsearch启动警告

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

内存锁定值的限制(max locked memory)

这个值只对普通用户起作用,对超级用户不起作用,这个问题是由于CAP_IPC_LOCK造成的.linux对内存是分页管理的,这意味着有不需要时,在物理内存的数据会被换到交换区或磁盘上.有需要时会被交换到物理内存,而将数据锁定到物理内存可以避免数据的换入/换出.采用锁定内存有两个理由:1)由于程序设计上需要,比如oracle等软件,就需要将数据锁定到物理内存.2)主要是安全上的需要,比如用户名和密码等等,被交换到swap或磁盘,有泄密的可能,所以一直将其锁定到物理内存.

查看项目进程限制,17497为pid

cat /proc/17497/limits

查看系统限制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增加2行,设为更大的值或者unlimited

  •       soft   memlock      unlimited
  •       hard   memlock      unlimited

其他可以使用ulimit添加自定义的限制(很多选项系统默认未开启),可以对一些不同用户进行限制

#
# - 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

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。