jvm-options.asciidoc 3.6 KB

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