executable-jna-tmpdir.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. * If you are using `systemd` to run {es} as a service, using the `systemctl`
  32. command, add the following line to the `[Service]` section of your
  33. `elasticsearch.service` unit file:
  34. +
  35. [source,text]
  36. --------------------------------------------
  37. Environment=ES_TMPDIR=/usr/share/elasticsearch/tmp
  38. --------------------------------------------
  39. If you need finer control over the location of these temporary files, you can
  40. also configure the path that JNA uses with the <<set-jvm-options,JVM flag>>
  41. `-Djna.tmpdir=<path>` and you can configure the path that `libffi` uses for its
  42. temporary files by setting the `LIBFFI_TMPDIR` environment variable. Future
  43. versions of {es} may need additional configuration, so you should prefer to set
  44. `ES_TMPDIR` wherever possible.