Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 67 additions & 14 deletions deploy-manage/deploy/self-managed/vm-max-map-count.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,90 @@

{{es}} uses a [`mmapfs`](elasticsearch://reference/elasticsearch/index-settings/store.md#mmapfs) directory by default to store its indices, which relies on memory-mapped files. As a result, the default operating system limit for the maximum number of memory mappings per process (`vm.max_map_count`) must be adequately high. If this limit is too low, the node might fail to start or encounter out-of-memory errors.

:::{admonition} Verify vm.max_map_count configuration
If the operating system's default `vm.max_map_count` value is `1048576` or higher, no configuration change is necessary. If the default value is lower than `1048576`, configure the `vm.max_map_count` parameter to `1048576`.
:::

The recommended `vm.max_map_count` value is `1048576` or higher. If the operating system's default value is lower than `1048576`, configure the `vm.max_map_count` parameter to `1048576`.

Check notice on line 16 in deploy-manage/deploy/self-managed/vm-max-map-count.md

View workflow job for this annotation

GitHub Actions / build / vale

Elastic.Versions: Use 'or later' instead of 'or higher' when referring to versions.

On Linux, you can increase the limits of the `vm.max_map_count` parameter by following this step as an account with `root` privileges:
If you installed {{es}} from the [RPM](/deploy-manage/deploy/self-managed/install-elasticsearch-with-rpm.md) or [Debian](/deploy-manage/deploy/self-managed/install-elasticsearch-with-debian-package.md) package on a `systemd`-based distribution, the {{es}} package sets `vm.max_map_count` for you. `systemd` applies the packaged value at every boot, and the package applies it again every time you install or upgrade {{es}}:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to give this new content its own heading, because it's not super clear that we have rpm/deb/archive info "forking"

Suggested change
If you installed {{es}} from the [RPM](/deploy-manage/deploy/self-managed/install-elasticsearch-with-rpm.md) or [Debian](/deploy-manage/deploy/self-managed/install-elasticsearch-with-debian-package.md) package on a `systemd`-based distribution, the {{es}} package sets `vm.max_map_count` for you. `systemd` applies the packaged value at every boot, and the package applies it again every time you install or upgrade {{es}}:
## Default virtual memory values
If you installed {{es}} from the [RPM](/deploy-manage/deploy/self-managed/install-elasticsearch-with-rpm.md) or [Debian](/deploy-manage/deploy/self-managed/install-elasticsearch-with-debian-package.md) package on a `systemd`-based distribution, the {{es}} package sets `vm.max_map_count` for you. `systemd` applies the packaged value at every boot, and the package applies it again every time you install or upgrade {{es}}. The value depends on your {{stack}} version:


* {applies_to}`stack: ga 9.6+` The package sets the value to `1048576`, so you don't need to change anything unless you want a different value.
* In versions earlier than 9.6, the package sets the value to `262144`, which is lower than the recommended `1048576`. To use `1048576`, you must override the packaged value, as described in [Persist the value across reboots and upgrades](#vm-max-map-count-persist).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* In versions earlier than 9.6, the package sets the value to `262144`, which is lower than the recommended `1048576`. To use `1048576`, you must override the packaged value, as described in [Persist the value across reboots and upgrades](#vm-max-map-count-persist).
* {applies_to}`stack: ga 9.0-9.5` The package sets the value to `262144`, which is lower than the recommended `1048576`. To use `1048576`, you must override the packaged value, as described in [Persist the value across reboots and upgrades](#vm-max-map-count-persist).


If you installed {{es}} from an archive (`.tar.gz`), no package sets the value, so you must configure it yourself in all versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no package involved here

Suggested change
If you installed {{es}} from an archive (`.tar.gz`), no package sets the value, so you must configure it yourself in all versions.
If you installed {{es}} from an archive (`.tar.gz`), the value is not set, so you must configure it yourself in all versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.




## Change the value temporarily [vm-max-map-count-temporary]

On Linux, you can change the running value of `vm.max_map_count` immediately by running the following command as an account with `root` privileges:

```sh
sysctl -w vm.max_map_count=1048576
```

To set this value permanently, update the `vm.max_map_count` setting in `/etc/sysctl.conf`.
This change doesn't persist across reboots, and on package installs, a package upgrade can also reset it. To keep the value, follow the steps in the next section.

To verify after rebooting, run:
## Persist the value across reboots and upgrades [vm-max-map-count-persist]

```sh
sysctl vm.max_map_count
```
On `systemd`-based distributions, the {{es}} RPM and Debian packages install `/usr/lib/sysctl.d/elasticsearch.conf`. `systemd` applies this file at every boot, and the package applies it again every time you install or upgrade {{es}}. To keep your own value, persist it where it takes precedence over the packaged file. How you do this depends on how you installed {{es}}.

::::::{tab-set}

::::{tab-item} RPM or Debian package (systemd)
1. Persist the value in a file named `/etc/sysctl.d/elasticsearch.conf`, the same name as the packaged file. A file with the same name in `/etc/sysctl.d/` replaces the one in `/usr/lib/sysctl.d/`, so your value is used instead of the packaged one:

```sh
echo "vm.max_map_count=1048576" | sudo tee /etc/sysctl.d/elasticsearch.conf
```

2. Apply the change immediately by running the same command that the package uses when it applies its own settings:

To reflect the change immediately, without rebooting, run:
```sh
sudo systemctl restart systemd-sysctl
```

3. Verify that the value is applied. To confirm that it persists, run the same command again after rebooting or after upgrading the {{es}} package:

```sh
sysctl vm.max_map_count
```

If you previously set `vm.max_map_count` in `/etc/sysctl.conf` or in another `sysctl.d` file, remove that entry so the old value doesn't conflict with the new one.

To see which configuration files are applied and in which order, run:

```sh
sudo sysctl --system
systemd-analyze cat-config sysctl.d
```
::::

::::{tab-item} Archive or other installation
If you installed {{es}} from an archive (`.tar.gz`), or on a system that doesn't use systemd, no packaged sysctl file exists, so there's nothing to override your value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zip? docker?


1. Persist the value by updating the `vm.max_map_count` setting in `/etc/sysctl.conf`:

While RPM and Debian packages attempt to configure this automatically, setting the value in `/etc/sysctl.conf` ensures that it takes precedence and that the correct value is applied, overriding any package-level defaults.
```sh
echo "vm.max_map_count=1048576" | sudo tee -a /etc/sysctl.conf
```

2. Apply the change immediately, without rebooting:

You can find out the current mmap count of a running {{es}} process using the following command, where `$PID` is the process ID of the running {{es}} process:
```sh
sudo sysctl --system
```

3. Verify that the value is applied. To confirm that it persists, run the same command again after rebooting:

```sh
sysctl vm.max_map_count
```
::::

::::::

## Check how many memory mappings {{es}} is using

To see how close a running {{es}} node is to the `vm.max_map_count` limit, count its current memory mappings. Run the following command, where `$PID` is the process ID of the running {{es}} process, and compare the result to the value from `sysctl vm.max_map_count`:

```sh
wc -l /proc/$PID/maps
```

Loading