From 921f56034a1bbbd61ad5bf54530075b1ff867c3e Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 4 Jan 2023 16:06:57 +0100 Subject: [PATCH] Increase max_map_count --- conf/90-max_map_count-opensearch.conf | 3 +++ scripts/backup | 6 ++++++ scripts/install | 19 +++++++++++++++---- scripts/restore | 12 ++++++++++++ scripts/upgrade | 13 +++++++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 conf/90-max_map_count-opensearch.conf diff --git a/conf/90-max_map_count-opensearch.conf b/conf/90-max_map_count-opensearch.conf new file mode 100644 index 0000000..f8aa694 --- /dev/null +++ b/conf/90-max_map_count-opensearch.conf @@ -0,0 +1,3 @@ +# Increase the number of allowed map count +# See: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index/#important-settings +vm.max_map_count=262144 diff --git a/scripts/backup b/scripts/backup index b47e9e7..bbc5726 100755 --- a/scripts/backup +++ b/scripts/backup @@ -56,6 +56,12 @@ ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="/etc/logrotate.d/$app" +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +ynh_backup --src_path="/etc/sysctl.d/90-max_map_count-opensearch.conf" + #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index ddfd848..8c4adae 100755 --- a/scripts/install +++ b/scripts/install @@ -71,10 +71,6 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= ynh_script_progression --message="Setting up source files..." --weight=15 -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" @@ -118,6 +114,21 @@ ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.op chmod 400 "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options" chown $app:$app "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options" + +#================================================= +# INCREASE MAX_MAP_COUNT +#================================================= +ynh_script_progression --message="Increasing maximum map count (sysctl)..." + +# Increase the maximum number of files inotify can monitor. +cp -a ../conf/90-max_map_count-opensearch.conf /etc/sysctl.d/ +# Then, reload the kernel configuration. +if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. +then + sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf +fi + + #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/restore b/scripts/restore index 40dfd55..fc9eff0 100755 --- a/scripts/restore +++ b/scripts/restore @@ -93,6 +93,18 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." + +ynh_restore_file --origin_path="/etc/sysctl.d/90-max_map_count-opensearch.conf" +if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. +then + sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf +fi + #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 58c778c..5717200 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -119,6 +119,19 @@ ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.op chmod 400 "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options" chown $app:$app "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options" +#================================================= +# INCREASE MAX_MAP_COUNT +#================================================= +ynh_script_progression --message="Increasing maximum map count (sysctl)..." + +# Increase the maximum number of files inotify can monitor. +cp -a ../conf/90-max_map_count-opensearch.conf /etc/sysctl.d/ +# Then, reload the kernel configuration. +if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. +then + sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf +fi + #================================================= # SETUP SYSTEMD #=================================================