jvm-options.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. [[jvm-options]]
  2. === Setting JVM options
  3. You should rarely need to change Java Virtual Machine (JVM) options. If you do,
  4. the most likely change is setting the <<heap-size,heap size>>. The remainder of
  5. this document explains in detail how to set JVM options. You can set options
  6. either with `jvm.options` files or with the `ES_JAVA_OPTS` environment variable.
  7. The preferred method of setting or overriding JVM options is via JVM options
  8. files. When installing from the tar or zip distributions, the root `jvm.options`
  9. configuration file is `config/jvm.options` and custom JVM options files can be
  10. added to `config/jvm.options.d/`. When installing from the Debian or RPM
  11. packages, the root `jvm.options` configuration file is
  12. ``/etc/elasticsearch/jvm.options` and custom JVM options files can be added to
  13. `/etc/elasticsearch/jvm.options.d/`. When using the <<docker, Docker
  14. distribution of {es}>> you can bind mount custom JVM options files into
  15. `/usr/share/elasticsearch/config/jvm.options.d/`. You should never need to
  16. modify the root `jvm.options` file instead preferring to use custom JVM options
  17. files. The processing ordering of custom JVM options is lexicographic.
  18. JVM options files must have the suffix '.options' and contain a line-delimited
  19. list of JVM arguments following a special syntax:
  20. * lines consisting of whitespace only are ignored
  21. * lines beginning with `#` are treated as comments and are ignored
  22. +
  23. [source,text]
  24. -------------------------------------
  25. # this is a comment
  26. -------------------------------------
  27. * lines beginning with a `-` are treated as a JVM option that applies
  28. independent of the version of the JVM
  29. +
  30. [source,text]
  31. -------------------------------------
  32. -Xmx2g
  33. -------------------------------------
  34. * lines beginning with a number followed by a `:` followed by a `-` are treated
  35. as a JVM option that applies only if the version of the JVM matches the number
  36. +
  37. [source,text]
  38. -------------------------------------
  39. 8:-Xmx2g
  40. -------------------------------------
  41. * lines beginning with a number followed by a `-` followed by a `:` are treated
  42. as a JVM option that applies only if the version of the JVM is greater than or
  43. equal to the number
  44. +
  45. [source,text]
  46. -------------------------------------
  47. 8-:-Xmx2g
  48. -------------------------------------
  49. * lines beginning with a number followed by a `-` followed by a number followed
  50. by a `:` are treated as a JVM option that applies only if the version of the
  51. JVM falls in the range of the two numbers
  52. +
  53. [source,text]
  54. -------------------------------------
  55. 8-9:-Xmx2g
  56. -------------------------------------
  57. * all other lines are rejected
  58. An alternative mechanism for setting Java Virtual Machine options is via the
  59. `ES_JAVA_OPTS` environment variable. For instance:
  60. [source,sh]
  61. ---------------------------------
  62. export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"
  63. ./bin/elasticsearch
  64. ---------------------------------
  65. When using the RPM or Debian packages, `ES_JAVA_OPTS` can be specified in the
  66. <<sysconfig,system configuration file>>.
  67. The JVM has a built-in mechanism for observing the `JAVA_TOOL_OPTIONS`
  68. environment variable. We intentionally ignore this environment variable in our
  69. packaging scripts. The primary reason for this is that on some OS (e.g., Ubuntu)
  70. there are agents installed by default via this environment variable that we do
  71. not want interfering with {es}.
  72. Additionally, some other Java programs support the `JAVA_OPTS` environment
  73. variable. This is *not* a mechanism built into the JVM but instead a convention
  74. in the ecosystem. However, we do not support this environment variable, instead
  75. supporting setting JVM options via the `jvm.options` file or the environment
  76. variable `ES_JAVA_OPTS` as above.