作者:mobiledu2502886131 | 来源:互联网 | 2022-12-10 08:56
我有一个针对ElasticSearch的systemd配置的问题.
[Unit]
Description=platform-elasticsearch
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
User={{ app_user }}
Group={{ app_group }}
EnvirOnment=ES_PATH_COnF=/platform/opt/elasticsearch-{{ elasticsearch.version }}/config
EnvirOnment=JAVA_HOME=/platform/opt/jdk{{ jdk.major_version }}_{{ jdk.minor_version }}
LimitAS=infinity
LimitRSS=infinity
LimitCORE=infinity
LimitNOFILE=100000
LimitMEMLOCK=100000
StandardOutput=syslog
StandardError=syslog
WorkingDirectory=/platform/var/app/elasticsearch
ExecStart=/platform/opt/elasticsearch-{{ elasticsearch.version }}/bin/elasticsearch
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s -TERM $MAINPID
TimeoutStopSec=60
# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143 0
Type=simple
Restart=on-failure
RestartSec=10
PIDFile=/platform/var/run/elasticsearch.pid
[Install]
WantedBy=multi-user.target
这似乎不允许我配置vm.max_map_count设置.
Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,359][INFO ][o.e.b.BootstrapChecks ] [1oQJNUK] bound or publishing to a non-loopback address, enforcing bootstrap checks
Jul 20 14:53:46 scratchpad elasticsearch: ERROR: [1] bootstrap checks failed
Jul 20 14:53:46 scratchpad elasticsearch: [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,376][INFO ][o.e.n.Node ] [1oQJNUK] stopping ...
Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,414][INFO ][o.e.n.Node ] [1oQJNUK] stopped
Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,414][INFO ][o.e.n.Node ] [1oQJNUK] closing ...
Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,445][INFO ][o.e.n.Node ] [1oQJNUK] closed
Jul 20 14:53:46 scratchpad systemd: platform-elasticsearch.service: main process exited, code=exited, status=78/n/a
具体问题如下:
Jul 20 14:53:46 scratchpad elasticsearch: [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
我已经能够使用以下命令在命令行上启动弹性搜索:
sudo su -c 'echo 262144 > "/proc/sys/vm/max_map_count"' && \
export JAVA_HOME=/platform/opt/jdk1.8.0_181 && \
export ES_PATH_COnF=/platform/opt/elasticsearch-6.3.1/config && \
/platform/opt/elasticsearch-6.3.1/bin/elasticsearch
任何人都可以告诉我为什么LimitMEMLOCK = 100000不起作用,以及如何从systemd中有效地设置max_map_count.
我还尝试设置以下内容:
cat /etc/security/limits.d/30_elastic_limits.conf
vagrant hard nofile 500000
vagrant hard memlock 262144
但这似乎被systemd完全忽略了.
帮助,现在有点绝望!
1> Val..:
Vivek的答案是正确的,但是,设置只会在会话期间持续.如果主机重新启动,则设置将重置为原始值.
如果要永久设置,则需要编辑/etc/sysctl.conf
并设置vm.max_map_count
为262144.
主机重新启动后,您可以通过运行验证设置是否仍然正确 sysctl vm.max_map_count
不要忘记重启或:sysctl --system
2> Vivek Pakmod..:
在Centos上,您可以使用以下命令:
sysctl -w vm.max_map_count=262144
3> 小智..:
从本质上说,这并不是一个答案,而是从docker容器的角度对有操作问题的任何人的澄清/捷径。我在Docker容器中运行的应用程序遇到了这个问题。而且正如nishant在这里解释的那样
您不需要在容器级别增加用于Elasticsearch的虚拟内存,可以通过运行以下命令为主机添加虚拟内存:
sudo sysctl -w vm.max_map_count=262144
然后重新启动您的docker-containers。
As explained by val above setting this max_map_count
this way won't persist upon the restart of the machine on which is running the docker container. and so you will need to save it in a more persistent manner as explained by him above.