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