为了提高elasticsearch的效率,我设置了禁用交换区(swapping),开始是只是修改了elasticsearch.yml
文件的bootstrap.memmory_lock
,但是设置后启动报错:
[1]: memory locking requested for elasticsearch process but memory is not locked
我的安装方式使用tar,启动方式为bin/elasticsearch
,这里还需要修改/etc/security/limits.conf
,不同的安装方式需要配置的文件不同,详情见https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html
添加以下两行到/etc/security/limits.conf
文件中,
user soft memlock unlimited
user hard memlock unlimited
其中,user
为运行elasticsearch
的用户
对于远程连接用户(使用putty等工具登陆服务器)来说设置好后退出当前对话(session),非远程连接用户重启机器。
然后使用,命令ulimit -a
检查是否设置成功
reference
https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration-memory.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html