jvm-options.asciidoc 3.2 KB

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