From 306170a671136de4ae1d524b490660c842c81980 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 11 Nov 2016 14:43:49 -0500 Subject: [PATCH] Set vm.max_map_count on systemd package install Our docs claim that we set vm.max_map_count automatically. This is not quite the case. The story is that on SysV init we set vm.max_map_count each time the service starts, which is good. On systemd, we create a sysctl.d conf file that sets vm.map_max_count, but this is only meaningful if the system is rebooted after package install. This commit modifies the post-install script so that we run systemd-sysctl so that the vm.max_map_count change occurs after package install without a reboot. --- distribution/src/main/packaging/scripts/postinst | 5 +++++ .../src/test/resources/packaging/scripts/os_package.bash | 1 + 2 files changed, 6 insertions(+) diff --git a/distribution/src/main/packaging/scripts/postinst b/distribution/src/main/packaging/scripts/postinst index 6d19e5f33c736..91042ffbf50ec 100644 --- a/distribution/src/main/packaging/scripts/postinst +++ b/distribution/src/main/packaging/scripts/postinst @@ -51,6 +51,11 @@ 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 +fi + if [ "x$IS_UPGRADE" != "xtrue" ]; then if command -v systemctl >/dev/null; then echo "### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd" diff --git a/qa/vagrant/src/test/resources/packaging/scripts/os_package.bash b/qa/vagrant/src/test/resources/packaging/scripts/os_package.bash index db274b64985fe..21ce874971a51 100644 --- a/qa/vagrant/src/test/resources/packaging/scripts/os_package.bash +++ b/qa/vagrant/src/test/resources/packaging/scripts/os_package.bash @@ -123,6 +123,7 @@ verify_package_installation() { assert_file "/usr/lib/systemd/system/elasticsearch.service" f root root 644 assert_file "/usr/lib/tmpfiles.d/elasticsearch.conf" f root root 644 assert_file "/usr/lib/sysctl.d/elasticsearch.conf" f root root 644 + [[ $(sysctl vm.max_map_count) =~ "vm.max_map_count = 262144" ]] fi if is_sysvinit; then