Elasticsearch 用systemctl启动报max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

已经修改了/etc/security/limits.conf ,把数值加到65536,用elasticsearch用户启动,一切正常,但一旦用systemctl启动,还是报max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] 而且,我的配置文件已经指定使用elasticsearch用户,诡异的错误。

其实出现这个问题,原因在于/etc/security/limits.conf里的配置只针对PAM认证登录用户有效,而Systemd有自己的一套配置。全局配置在/etc/systemd/system.conf和/etc/systemd/user.conf,也可以对单个服务做配置,所以,elasticsearch的脚本要做下修改:

[Unit]
Description=Elasticsearch

[Service]
Environment=JAVA_HOME=/usr/local/jdk1.8.0_171
LimitCORE=infinity
LimitNOFILE=65536
LimitNPROC=65536
ExecStart=/usr/local/elasticsearch-6.3.1/bin/elasticsearch
User=elasticsearch
Group=elasticsearch

[Install]
WantedBy=multi-user.target

© 2018, 冰冻鱼. 请尊重作者劳动成果,复制转载保留本站链接! 应用开发笔记