Skip to content

Commit

Permalink
Enable bootstrap memory lock
Browse files Browse the repository at this point in the history
- update pam_limits for bootstrap memory lock
- add entry for the elasticsearch user for maximum number of open files
- ensure Ubuntu uses the limits.conf file for init.d
- set MAX_LOCKED_MEMORY in /etc/default/elasticsearch,
which is required for bootstrap memory lock to work successfully.
- remove commented lines that make changes to pam_limits; these do
not appear to be required.

Closes elastic#94
  • Loading branch information
russcam committed Feb 22, 2018
1 parent 9034d87 commit 0fce0d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ Check out our [examples repository](https://github.com/elastic/azure-marketplace
</td><td><code>""</code></td></tr>

<tr><td>esHeapSize</td><td>integer</td>
<td>The size, in megaytes, of memory to allocate on each Elasticsearch node for the JVM heap. If unspecified, 50% of the available memory will be allocated to Elasticsearch heap, up to a maximum of 31744 MB.
Take a look at <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html" target="_blank">the Elasticsearch documentation</a> for more information. <strong>This is an expert level feature</strong>
<td>The size, in megabytes, of memory to allocate on each Elasticsearch node for the JVM heap. If unspecified, 50% of the available memory will be allocated to Elasticsearch heap, up to a maximum of 31744MB (~32GB).
Take a look at <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html" target="_blank">the Elasticsearch documentation</a> for more information. <strong>This is an expert level feature - setting a heap size larger than available memory on the Elasticsearch VM SKU will fail the deployment.</strong>
</td><td><code>0</code></td></tr>

<tr><td>kibana</td><td>string</td>
Expand Down
2 changes: 1 addition & 1 deletion src/mainTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"type": "int",
"defaultValue": 0,
"metadata": {
"description": "The size, in megabytes, of memory to allocate on each Elasticsearch node for the JVM heap. If unspecified, 50% of the available memory will be allocated to Elasticsearch heap, up to a maximum of 31744 MB."
"description": "The size, in megabytes, of memory to allocate on each Elasticsearch node for the JVM heap. If unspecified, 50% of the available memory will be allocated to Elasticsearch heap, up to a maximum of 31744MB (~32GB)."
}
},
"kibana": {
Expand Down
36 changes: 21 additions & 15 deletions src/scripts/elasticsearch-ubuntu-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,13 @@ configure_elasticsearch_yaml()
fi

# Swap is disabled by default in Ubuntu Azure VMs, no harm in adding memory lock
# if dpkg --compare-versions "$ES_VERSION" ">=" "2.4.0"; then
# log "[configure_elasticsearch_yaml] Setting bootstrap.memory_lock: true"
# echo "bootstrap.memory_lock: true" >> $ES_CONF
# else
# log "[configure_elasticsearch_yaml] Setting bootstrap.mlockall: true"
# echo "bootstrap.mlockall: true" >> $ES_CONF
# fi
if dpkg --compare-versions "$ES_VERSION" ">=" "2.4.0"; then
log "[configure_elasticsearch_yaml] Setting bootstrap.memory_lock: true"
echo "bootstrap.memory_lock: true" >> $ES_CONF
else
log "[configure_elasticsearch_yaml] Setting bootstrap.mlockall: true"
echo "bootstrap.mlockall: true" >> $ES_CONF
fi
}

configure_elasticsearch()
Expand Down Expand Up @@ -834,14 +834,20 @@ configure_os_properties()
# Increase maximum mmap count
echo "vm.max_map_count = 262144" >> /etc/sysctl.conf

# Verify this is necessary on azure
# ML: 80% certain i verified this but will do so again
#echo "elasticsearch - nofile 65536" >> /etc/security/limits.conf
#echo "elasticsearch - memlock unlimited" >> /etc/security/limits.conf
#echo "session required pam_limits.so" >> /etc/pam.d/su
#echo "session required pam_limits.so" >> /etc/pam.d/common-session
#echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive
#echo "session required pam_limits.so" >> /etc/pam.d/sudo
# Update pam_limits for bootstrap memory lock
echo "# allow user 'elasticsearch' mlockall" >> /etc/security/limits.conf
echo "elasticsearch soft memlock unlimited" >> /etc/security/limits.conf
echo "elasticsearch hard memlock unlimited" >> /etc/security/limits.conf

# Required for bootstrap memory lock
echo "MAX_LOCKED_MEMORY=unlimited" >> /etc/default/elasticsearch

# Maximum number of open files for elasticsearch user
echo "elasticsearch - nofile 65536" >> /etc/security/limits.conf

# Ubuntu ignores the limits.conf file for processes started by init.d by default, so enable them
echo "session required pam_limits.so" >> /etc/pam.d/su

log "[configure_os_properties] configured operating system level configuration"
}

Expand Down

0 comments on commit 0fce0d4

Please sign in to comment.