executable-jna-tmpdir.asciidoc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. [[executable-jna-tmpdir]]
  2. === JNA temporary directory not mounted with `noexec`
  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`. Note that the exception message can
  17. differ amongst JVM versions. Additionally, the components of {es} that rely on
  18. execution of native code via JNA may fail with messages indicating that it is
  19. `because JNA is not available`.
  20. To resolve these problems, either remove the `noexec` option from your `/tmp`
  21. filesystem, or configure {es} to use a different location for its temporary
  22. directory by setting the <<es-tmpdir,`$ES_TMPDIR`>> environment variable. For
  23. instance:
  24. ["source","sh",subs="attributes"]
  25. --------------------------------------------
  26. export ES_TMPDIR=/usr/share/elasticsearch/tmp
  27. --------------------------------------------
  28. Alternatively, you can configure the path that JNA uses for its temporary files
  29. with the <<set-jvm-options,JVM flag>> `-Djna.tmpdir=<path>` and you can
  30. configure the path that `libffi` uses for its temporary files with the
  31. `LIBFFI_TMPDIR` environment variable.