Browse Source

Add option to skip kernel parameters on install

During package install on systemd-based systems, we try to set
vm.max_map_count. On some systems (e.g., containers), users do not have
the ability to tune these parameters from within the container. This
commit provides an option for these users to skip setting such kernel
parameters.

Relates #21899
Jason Tedor 8 years ago
parent
commit
32df032c59

+ 11 - 4
distribution/src/main/packaging/scripts/postinst

@@ -52,10 +52,17 @@ case "$1" in
 esac
 
 # to pick up /usr/lib/sysctl.d/elasticsearch.conf
-if command -v /usr/lib/systemd/systemd-sysctl > /dev/null; then
-    /usr/lib/systemd/systemd-sysctl
-elif command -v /lib/systemd/systemd-sysctl > /dev/null; then
-    /lib/systemd/systemd-sysctl
+if [ "${ES_SKIP_SET_KERNEL_PARAMETERS:-false}" == "false" ]; then
+    if command -v /usr/lib/systemd/systemd-sysctl > /dev/null; then
+        /usr/lib/systemd/systemd-sysctl
+    elif command -v /lib/systemd/systemd-sysctl > /dev/null; then
+        /lib/systemd/systemd-sysctl
+    fi
+elif [ "$ES_SKIP_SET_KERNEL_PARAMETERS" == "true" ]; then
+    echo "skipping setting kernel parameters"
+else
+    echo "unrecognized value [$ES_SKIP_SET_KERNEL_PARAMETERS] for ES_SKIP_SET_KERNEL_PARAMETERS; must [false] (default) or [true]"
+    exit 1
 fi
 
 if [ "x$IS_UPGRADE" != "xtrue" ]; then

+ 1 - 0
docs/reference/setup/install/deb.asciidoc

@@ -96,6 +96,7 @@ Examine +/etc/apt/sources.list.d/elasticsearch-{major-version}.list+ for the dup
 
 endif::[]
 
+include::skip-set-kernel-parameters.asciidoc[]
 
 [[install-deb]]
 ==== Download and install the Debian package manually

+ 2 - 0
docs/reference/setup/install/rpm.asciidoc

@@ -112,6 +112,8 @@ sudo rpm --install elasticsearch-{version}.rpm
 
 endif::[]
 
+include::skip-set-kernel-parameters.asciidoc[]
+
 include::init-systemd.asciidoc[]
 
 [[rpm-running-init]]

+ 2 - 0
docs/reference/setup/install/skip-set-kernel-parameters.asciidoc

@@ -0,0 +1,2 @@
+NOTE: On systemd-based distributions, the installation scripts will attempt to set kernel parameters (e.g.,
+`vm.max_map_count`); you can skip this by setting the environment variable `ES_SKIP_SET_KERNEL_PARAMETERS` to `true`.