title: Elasticsearch: Max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
body: <p>I have an issue with a systemd config for ElasticSearch.</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>This does not seem to let me configure the vm.max_map_count setting.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The specific issue is the following:</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>I have been able to start elastic search on the commandline with the following:</p>
  
  <pre><code>sudo su -c 'echo 262144 &gt; "/proc/sys/vm/max_map_count"' &amp;&amp; \ 
  export JAVA_HOME=/platform/opt/jdk1.8.0_181 &amp;&amp; \
  export ES_PATH_CONF=/platform/opt/elasticsearch-6.3.1/config &amp;&amp; \
  /platform/opt/elasticsearch-6.3.1/bin/elasticsearch 
  </code></pre>
  
  <p>can anyone tell me why LimitMEMLOCK=100000 does not work, and how I can effectively set max_map_count from within systemd.</p>
  
  <p>I have also tried to set the following:</p>
  
  <pre><code>cat /etc/security/limits.d/30_elastic_limits.conf
  
  vagrant       hard    nofile     500000
  vagrant       hard    memlock     262144
  </code></pre>
  
  <p>but this seems to be totally ignored by systemd.</p>