為了提高elasticsearch的效率,我設(shè)置了禁用交換區(qū)(swapping),開始是只是修改了elasticsearch.yml文件的bootstrap.memmory_lock,但是設(shè)置后啟動報錯:
[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的用戶
對于遠(yuǎn)程連接用戶(使用putty等工具登陸服務(wù)器)來說設(shè)置好后退出當(dāng)前對話(session),非遠(yuǎn)程連接用戶重啟機器。
然后使用,命令ulimit -a檢查是否設(shè)置成功

image.png
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