官网说明:

elasticsearch官网建议生产环境需要设置bootstrap.memory_lock: true

官网的解释 是:发生系统swapping的时候ES节点的性能会非常差,也会影响节点的稳定性。所以要不惜一切代价来避免swapping。swapping会导致Java GC的周期延迟从毫秒级恶化到分钟,更严重的是会引起节点响应延迟甚至脱离集群。

所以最好限制住elasticsearch占用的内存情况,可选少用swap

错误内容:

开启bootstrap.memory_lock: true后,在Elasticsearch集群启动的时候,会报如下错误

ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked

我使用docker-compose布署的时候,集群一直在重启失败间循环!

解决方法:

方案1:

此方案适用于非systemd管理的linux发行版,centos 6及以下可以仅通过这个方案解决

临时解决方法:
ulimit -l unlimited
永久解决方法:

root权限编辑/etc/security/limits.conf

$ sudo vim /etc/security/limits.conf

添加如下内容,保存退出

* soft memlock unlimited
* hard memlock unlimited

这里的*代表的是所有用户名称,可以更换为指定用户名

另:这里有个坑就是如果/etc/security/limits.d文件夹下的有配置文件,那么会覆盖刚才修改的文件,所以请确保该目录没有其它文件,如有请联系运维人员确认删除

修改/etc/sysctl.conf

sudo echo "vm.swappiness=0" >> /etc/sysctl.conf

这个参数的作用是告诉Linux内核尽少的使用swap分区,不等于禁用swap,通过少使用swap来提高性能。

如果想立即生效而不是重启之后让sysctl.conf生效,请使用sysctl -p

重新登录或重启服务器方可生效

方案2:

适用于systemd管理的发行版,有文章提到centos 7需要使用此方案,本人使用debian 9.9.0 亲测解决问题,推荐先完成上边的方案后尝试本方案

这里还是推荐使用上边方法的第3步,尽少使用swap分区

在Centos7系统中,使用Systemd替代了之前的SysV。/etc/security/limits.conf文件的配置作用域缩小了。/etc/security/limits.conf的配置,只适用于通过PAM认证登录用户的资源限制,它对systemd的service的资源限制不生效。因此登录用户的限制,通过/etc/security/limits.conf与/etc/security/limits.d下的文件设置即可。

对于systemd service的资源设置,则需修改全局配置,全局配置文件放在/etc/systemd/system.conf和/etc/systemd/user.conf,同时也会加载两个对应目录中的所有.conf文件/etc/systemd/system.conf.d/.conf和/etc/systemd/user.conf.d/.conf。system.conf是系统实例使用的,user.conf是用户实例使用的。

全局生效方式:
sudo vim /etc/systemd/system.conf

最下方添加

DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity

保存, 重启系统

当然由于我是使用的docker,而不是包管理器安装的,给出的是全局的方案

局部生效方式:(针对包管理器安装elasticsearch的形式)
sudo systemctl edit elasticsearch

此命令会在/etc/systemd/system下创建elasticsearch.service.d/override.conf文件

添加如下内容

[Service]
LimitMEMLOCK=infinity

保存,退出,执行如下命令生效

sudo systemctl daemon-reload

如未生效,请尝试重启系统

压缩包版测试

针对使用tar.gz包,指定内存参考如图



我们按图索骥使用命令ES_JAVA_OPTS="-Xms512m -Xmx512m" ./bin/elasticsearch

如果此时出现
[2019-06-20T07:01:36,305][WARN ][o.e.b.JNANatives ] [node-1] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2019-06-20T07:01:36,340][WARN ][o.e.b.JNANatives ] [node-1] This can result in part of the JVM being swapped out.
[2019-06-20T07:01:36,343][WARN ][o.e.b.JNANatives ] [node-1] Increase RLIMIT_MEMLOCK, soft limit: 16777216, hard limit: 16777216
[2019-06-20T07:01:36,343][WARN ][o.e.b.JNANatives ] [node-1] These can be adjusted by modifying /etc/security/limits.conf, for example:
# allow user 'hellxz' mlockall
hellxz soft memlock unlimited
hellxz hard memlock unlimited
请再尝试加上第一种方案,两种方案同时使用

以上就是这些内容,希望能对读者有所帮助

声明,禁止布布扣、码迷、马开东、01海、colabug等网站复制转发此文章,其他请保留文章出处

【已解决】ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked的更多相关文章

  1. ES解决bootstrap checks failed, memory locking requested for elasticsearch process but memory is not locked问题

    问题描述: ERROR: [1] bootstrap checks failed[1]: memory locking requested for elasticsearch process but ...

  2. elasticsearch报错之 memory locking requested for elasticsearch process but memory is not locked

    安装elasticsearch报错如下: [2019-01-14T03:57:16,453][ERROR][o.e.b.Bootstrap ] [ip-172-31-30-62.ec2.interna ...

  3. elasticsearch6.4 memory locking requested for elasticsearch process but memory is not locked

    [2018-10-18T05:28:57,713][ERROR][o.e.b.Bootstrap ] [node-45] node validation exception[1] bootstrap ...

  4. elasticsearch6.4 memory locking requested for elasticsearch process but memory is not locked 终极解决

    echo "es hard memlock unlimited">>/etc/security/limits.confecho "es soft memloc ...

  5. ERROR: bootstrap checks failed

    错误描述:Linux默认配置的参数过小,需要自己设置 max file descriptors [4096] for elasticsearch process is too low, increas ...

  6. 启动Sonar报错,ERROR: [1] bootstrap checks failed [1]: system call filters failed to install

    错误提示信息: ERROR: [1] bootstrap checks failed[1]: system call filters failed to install; check the logs ...

  7. docker 启动 容器----bootstrap checks failed

    错误信息: bootstrap checks failed 解决方法: 1.修改elasticsearch.yml配置文件,允许外网访问. vim config/elasticsearch.yml,增 ...

  8. ElasticSearch启动报错,bootstrap checks failed

    修改elasticsearch.yml配置文件,允许外网访问. vim config/elasticsearch.yml# 增加 network.host: 0.0.0.0 启动失败,检查没有通过,报 ...

  9. idea中解决Error:java: Compilation failed: internal java compiler error的问题

    项目中,使用gradle做项目构建,当我们想更改JDK的版本时,报以下错误: Information:Using javac 1.8.0_111 to compile java sourcesInfo ...

随机推荐

  1. ios开发-常见的项目文件介绍

    一.项目文件结构示意图 二.文件介绍 1.products文件夹:主要用于mac电脑开发的可执行文件,ios开发用不到这个文件 2.frameworks文件夹主要用来放依赖的框架 3.test文件夹是 ...

  2. elasticsearch全文搜索

    1.创建索引 PUT 192.168.100.102:9200/news 2.创建mapping POST 192.168.100.102:9200/news/new/_mapping { " ...

  3. 有了Git这些操作,我再也不怕开发了!

    Git 是什么? Git 是一个分布式的代码管理容器,本地和远端都保有一份相同的代码. Git 仓库主要是由是三部分组成:本地代码,缓存区,提交历史. Git 有哪些常规操作? Git的常规操作你了解 ...

  4. redis问题集结

    redis和memcached比较? redis中数据库默认是多少个db 及作用? python操作redis的模块? 如果redis中的某个列表中的数据量非常大,如果实现循环显示每一个值? redi ...

  5. 安装ipython解释器

    安装ipython解释器 1.安装ipython,指定douban源下载 pip3 install -i https://pypi.douban.com/simple ipython 2.安装朱皮特 ...

  6. [BZOJ2056]gift? 高精度?

    Description Input 输入的第一行为一个整数t. 接下来t行,每行包含九个自然数. Output 输出t行 每行一个整数,表示\(2^a+2^b+2^c+2^d+2^e+2^f+2^g+ ...

  7. bzoj1925 [Sdoi2010] 地精部落【DP】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1925 一个多月前“过”了这道题,还自欺欺人地认为懂了这道题,这直接导致了昨晚多校联测2的T3 ...

  8. Ubuntu install and uinstall

    一.Ubuntu中软件安装方法 1.APT方式 (1)普通安装:apt-get install softname1 softname2 -; (2)修复安装:apt-get -f install so ...

  9. k-substrings Codeforces - 961F

    不会做.. 官方题解: 1.枚举某个前缀(指题目要求的相同前后缀中的前缀)的中心位置i,那么对应后缀的中心位置已经确定了(n-i+1),可以二分答案求出对于每个中心位置i最大的符合要求的相同前后缀(设 ...

  10. IOS 绘制PDF -转

    -(void)createPdf:(UIImage *)img andText:(NSString *)text{ NSArray *paths = NSSearchPathForDirectorie ...