jvm-options.asciidoc 2.9 KB

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