advanced-configuration.asciidoc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. [[advanced-configuration]]
  2. === Advanced configuration
  3. Modifying advanced settings is generally not recommended and could negatively
  4. impact performance and stability. Using the {es}-provided defaults
  5. is recommended in most circumstances.
  6. [[set-jvm-options]]
  7. ==== Set JVM options
  8. If needed, you can override the default JVM options by adding custom options
  9. files (preferred) or setting the `ES_JAVA_OPTS` environment variable.
  10. JVM options files must have the suffix '.options' and contain a line-delimited
  11. list of JVM arguments. JVM processes options files in lexicographic order.
  12. Where you put the JVM options files depends on the type of installation:
  13. * tar.gz or .zip: Add custom JVM options files to `config/jvm.options.d/`.
  14. * Debian or RPM: Add custom JVM options files to `/etc/elasticsearch/jvm.options.d/`.
  15. * Docker: Bind mount custom JVM options files into
  16. `/usr/share/elasticsearch/config/jvm.options.d/`.
  17. NOTE: Do not modify the root `jvm.options` file. Use files in `jvm.options.d/` instead.
  18. [[jvm-options-syntax]]
  19. ===== JVM options syntax
  20. A JVM options file contains a line-delimited list of JVM arguments.
  21. Arguments are preceded by a dash (`-`).
  22. To apply the setting to specific versions, prepend the version
  23. or a range of versions followed by a colon.
  24. * Apply a setting to all versions:
  25. +
  26. [source,text]
  27. -------------------------------------
  28. -Xmx2g
  29. -------------------------------------
  30. * Apply a setting to a specific version:
  31. +
  32. [source,text]
  33. -------------------------------------
  34. 17:-Xmx2g
  35. -------------------------------------
  36. * Apply a setting to a range of versions:
  37. +
  38. [source,text]
  39. -------------------------------------
  40. 17-18:-Xmx2g
  41. -------------------------------------
  42. +
  43. To apply a setting to a specific version and any later versions,
  44. omit the upper bound of the range.
  45. For example, this setting applies to Java 8 and later:
  46. +
  47. [source,text]
  48. -------------------------------------
  49. 17-:-Xmx2g
  50. -------------------------------------
  51. Blank lines are ignored. Lines beginning with `#` are treated as comments
  52. and ignored. Lines that aren't commented out and aren't recognized
  53. as valid JVM arguments are rejected and {es} will fail to start.
  54. [[jvm-options-env]]
  55. ===== Use environment variables to set JVM options
  56. In production, use JVM options files to override the
  57. default settings. In testing and development environments,
  58. you can also set JVM options through the `ES_JAVA_OPTS` environment variable.
  59. [source,sh]
  60. ---------------------------------
  61. export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"
  62. ./bin/elasticsearch
  63. ---------------------------------
  64. If you're using the RPM or Debian packages, you can specify
  65. `ES_JAVA_OPTS` in the <<sysconfig,system configuration file>>.
  66. NOTE: {es} ignores the `JAVA_TOOL_OPTIONS` and `JAVA_OPTS` environment variables.
  67. [[set-jvm-heap-size]]
  68. ==== Set the JVM heap size
  69. By default, {es} automatically sets the JVM heap size based on a node's
  70. <<node-roles,roles>> and total memory.
  71. Using the default sizing is recommended for most production environments.
  72. To override the default heap size, set the minimum and maximum heap size
  73. settings, `Xms` and `Xmx`. The minimum and maximum values must be the same.
  74. The heap size should be based on the available RAM:
  75. * Set `Xms` and `Xmx` to no more than 50% of your total memory. {es} requires
  76. memory for purposes other than the JVM heap. For example, {es} uses
  77. off-heap buffers for efficient network communication and relies
  78. on the operating system's filesystem cache for
  79. efficient access to files. The JVM itself also requires some memory. It's
  80. normal for {es} to use more memory than the limit
  81. configured with the `Xmx` setting.
  82. +
  83. NOTE: When running in a container, such as <<docker,Docker>>, total memory is
  84. defined as the amount of memory visible to the container, not the total system
  85. memory on the host.
  86. * Set `Xms` and `Xmx` to no more than the threshold for compressed ordinary
  87. object pointers (oops). The exact threshold varies but 26GB is safe on most
  88. systems and can be as large as 30GB on some systems. To verify you are under the
  89. threshold, check the {es} log for an entry like this:
  90. +
  91. [source,txt]
  92. ----
  93. heap size [1.9gb], compressed ordinary object pointers [true]
  94. ----
  95. +
  96. Or check the `jvm.using_compressed_ordinary_object_pointers` value for the nodes using the <<cluster-nodes-info,nodes info API>>:
  97. +
  98. [source,console]
  99. ----
  100. GET _nodes/_all/jvm
  101. ----
  102. The more heap available to {es}, the more memory it can use for its internal
  103. caches. This leaves less memory for the operating system to use
  104. for the filesystem cache. Larger heaps can also cause longer garbage
  105. collection pauses.
  106. To configure the heap size, add the `Xms` and `Xmx` JVM arguments to a
  107. custom JVM options file with the extension `.options` and
  108. store it in the `jvm.options.d/` directory.
  109. For example, to set the maximum heap size to 2GB, set both `Xms` and `Xmx` to `2g`:
  110. [source,txt]
  111. ------------------
  112. -Xms2g
  113. -Xmx2g
  114. ------------------
  115. For testing, you can also set the heap sizes using the `ES_JAVA_OPTS`
  116. environment variable:
  117. [source,sh]
  118. ------------------
  119. ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch
  120. ------------------
  121. The `ES_JAVA_OPTS` variable overrides all other JVM
  122. options. We do not recommend using `ES_JAVA_OPTS` in production.
  123. NOTE: If you are running {es} as a Windows service, you can change the heap size
  124. using the service manager. See <<windows-service>>.
  125. [[readiness-tcp-port]]
  126. ===== Enable the Elasticsearch TCP readiness port
  127. preview::[]
  128. If configured, a node can open a TCP port when the node is in a ready state. A node is deemed
  129. ready when it has successfully joined a cluster. In a single node configuration, the node is
  130. said to be ready, when it's able to accept requests.
  131. To enable the readiness TCP port, use the `readiness.port` setting. The readiness service will bind to
  132. all host addresses.
  133. If the node leaves the cluster, or the <<put-shutdown,Shutdown API>> is used to mark the node
  134. for shutdown, the readiness port is immediately closed.
  135. A successful connection to the readiness TCP port signals that the {es} node is ready. When a client
  136. connects to the readiness port, the server simply terminates the socket connection. No data is sent back
  137. to the client. If a client cannot connect to the readiness port, the node is not ready.