executable-jna-tmpdir.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [[executable-jna-tmpdir]]
  2. === Ensure JNA temporary directory permits executables
  3. [NOTE]
  4. This is only relevant for Linux.
  5. {es} uses the Java Native Access (JNA) library, and another library called
  6. `libffi`, for executing some platform-dependent native code. On Linux, the
  7. native code backing these libraries is extracted at runtime into a temporary
  8. directory and then mapped into executable pages in {es}'s address space. This
  9. requires the underlying files not to be on a filesystem mounted with the
  10. `noexec` option.
  11. By default, {es} will create its temporary directory within `/tmp`. However,
  12. some hardened Linux installations mount `/tmp` with the `noexec` option by
  13. default. This prevents JNA and `libffi` from working correctly. For instance,
  14. at startup JNA may fail to load with an `java.lang.UnsatisfiedLinkerError`
  15. exception or with a message that says something similar to
  16. `failed to map segment from shared object`, or `libffi` may report a message
  17. such as `failed to allocate closure`. Note that the exception messages can
  18. differ between JVM versions. Additionally, the components of {es} that rely on
  19. execution of native code via JNA may fail with messages indicating that it is
  20. `because JNA is not available`.
  21. To resolve these problems, either remove the `noexec` option from your `/tmp`
  22. filesystem, or configure {es} to use a different location for its temporary
  23. directory by setting the <<es-tmpdir,`$ES_TMPDIR`>> environment variable. For
  24. instance:
  25. * If you are running {es} directly from a shell, set `$ES_TMPDIR` as follows:
  26. +
  27. ["source","sh",subs="attributes"]
  28. --------------------------------------------
  29. export ES_TMPDIR=/usr/share/elasticsearch/tmp
  30. --------------------------------------------
  31. * For installs done through RPM or DEB packages, the environment variable needs
  32. to be set through the <<sysconfig,system configuration file>>.
  33. * If you are using `systemd` to run {es} as a service, add the following
  34. line to the `[Service]` section in a <<systemd,service override file>>:
  35. +
  36. [source,text]
  37. --------------------------------------------
  38. Environment=ES_TMPDIR=/usr/share/elasticsearch/tmp
  39. --------------------------------------------
  40. If you need finer control over the location of these temporary files, you can
  41. also configure the path that JNA uses with the <<set-jvm-options,JVM flag>>
  42. `-Djna.tmpdir=<path>` and you can configure the path that `libffi` uses for its
  43. temporary files by setting the `LIBFFI_TMPDIR` environment variable. Future
  44. versions of {es} may need additional configuration, so you should prefer to set
  45. `ES_TMPDIR` wherever possible.
  46. NOTE: {es} does not remove its temporary directory. You should remove leftover
  47. temporary directories while {es} is not running. It is best to do this
  48. automatically, for instance on each reboot. If you are running on Linux, you
  49. can achieve this by using the
  50. link:https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html[tmpfs] file
  51. system.