configuration.asciidoc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. [[settings]]
  2. == Configuring {es}
  3. {es} ships with good defaults and requires very little configuration.
  4. Most settings can be changed on a running cluster using the
  5. <<cluster-update-settings>> API.
  6. The configuration files should contain settings which are node-specific (such
  7. as `node.name` and paths), or settings which a node requires in order to be
  8. able to join a cluster, such as `cluster.name` and `network.host`.
  9. [[config-files-location]]
  10. [discrete]
  11. === Config files location
  12. {es} has three configuration files:
  13. * `elasticsearch.yml` for configuring {es}
  14. * `jvm.options` for configuring {es} JVM settings
  15. * `log4j2.properties` for configuring {es} logging
  16. These files are located in the config directory, whose default location depends
  17. on whether or not the installation is from an archive distribution (`tar.gz` or
  18. `zip`) or a package distribution (Debian or RPM packages).
  19. For the archive distributions, the config directory location defaults to
  20. `$ES_HOME/config`. The location of the config directory can be changed via the
  21. `ES_PATH_CONF` environment variable as follows:
  22. [source,sh]
  23. -------------------------------
  24. ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch
  25. -------------------------------
  26. Alternatively, you can `export` the `ES_PATH_CONF` environment variable via the
  27. command line or via your shell profile.
  28. For the package distributions, the config directory location defaults to
  29. `/etc/elasticsearch`. The location of the config directory can also be changed
  30. via the `ES_PATH_CONF` environment variable, but note that setting this in your
  31. shell is not sufficient. Instead, this variable is sourced from
  32. `/etc/default/elasticsearch` (for the Debian package) and
  33. `/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the
  34. `ES_PATH_CONF=/etc/elasticsearch` entry in one of these files accordingly to
  35. change the config directory location.
  36. [discrete]
  37. === Config file format
  38. The configuration format is https://yaml.org/[YAML]. Here is an
  39. example of changing the path of the data and logs directories:
  40. [source,yaml]
  41. --------------------------------------------------
  42. path:
  43. data: /var/lib/elasticsearch
  44. logs: /var/log/elasticsearch
  45. --------------------------------------------------
  46. Settings can also be flattened as follows:
  47. [source,yaml]
  48. --------------------------------------------------
  49. path.data: /var/lib/elasticsearch
  50. path.logs: /var/log/elasticsearch
  51. --------------------------------------------------
  52. In YAML, you can format non-scalar values as sequences:
  53. [source,yaml]
  54. ----
  55. discovery.seed_hosts:
  56. - 192.168.1.10:9300
  57. - 192.168.1.11
  58. - seeds.mydomain.com
  59. ----
  60. Though less common, you can also format non-scalar values as arrays:
  61. [source,yaml]
  62. ----
  63. discovery.seed_hosts: ["192.168.1.10:9300", "192.168.1.11", "seeds.mydomain.com"]
  64. ----
  65. [discrete]
  66. === Environment variable substitution
  67. Environment variables referenced with the `${...}` notation within the
  68. configuration file will be replaced with the value of the environment
  69. variable. For example:
  70. [source,yaml]
  71. --------------------------------------------------
  72. node.name: ${HOSTNAME}
  73. network.host: ${ES_NETWORK_HOST}
  74. --------------------------------------------------
  75. Values for environment variables must be simple strings. Use a comma-separated string to provide values that {es} will parse as a list. For example, {es} will split the following string into a list of values for the `${HOSTNAME}` environment variable:
  76. [source,yaml]
  77. ----
  78. export HOSTNAME="host1,host2"
  79. ----
  80. [discrete]
  81. [[cluster-setting-types]]
  82. === Cluster and node setting types
  83. Cluster and node settings can be categorized based on how they are configured:
  84. [[dynamic-cluster-setting]]
  85. Dynamic::
  86. +
  87. --
  88. // tag::cluster-setting-precedence[]
  89. You can configure and update dynamic settings on a running cluster using the
  90. ifdef::strip-api-link[]
  91. cluster update settings API.
  92. endif::strip-api-link[]
  93. ifndef::strip-api-link[]
  94. <<cluster-update-settings,cluster update settings API>>.
  95. endif::strip-api-link[]
  96. You can also configure dynamic settings locally on an unstarted or shut down
  97. node using `elasticsearch.yml`.
  98. Updates made using the cluster update settings API can be _persistent_, which
  99. apply across cluster restarts, or _transient_, which reset after a cluster
  100. restart. You can also reset transient or persistent settings by assigning them
  101. a `null` value using the API.
  102. If you configure the same setting using multiple methods, {es} applies the
  103. settings in following order of precedence:
  104. 1. Transient setting
  105. 2. Persistent setting
  106. 3. `elasticsearch.yml` setting
  107. 4. Default setting value
  108. For example, you can apply a transient setting to override a persistent setting
  109. or `elasticsearch.yml` setting. However, a change to an `elasticsearch.yml`
  110. setting will not override a defined transient or persistent setting.
  111. [TIP]
  112. ====
  113. If you use {ess}, use the {cloud}/ec-add-user-settings.html[user settings]
  114. feature to configure all cluster settings. This method lets {ess} automatically
  115. reject unsafe settings that could break your cluster.
  116. If you run {es} on your own hardware, use the
  117. ifdef::strip-api-link[]
  118. cluster update settings API
  119. endif::strip-api-link[]
  120. ifndef::strip-api-link[]
  121. <<cluster-update-settings,cluster update settings API>>
  122. endif::strip-api-link[]
  123. to configure dynamic cluster settings. Only use `elasticsearch.yml` for static
  124. cluster settings and node settings. The API doesn't require a restart and
  125. ensures a setting's value is the same on all nodes.
  126. ====
  127. include::{es-repo-dir}/cluster/update-settings.asciidoc[tag=transient-settings-warning]
  128. // end::cluster-setting-precedence[]
  129. --
  130. [[static-cluster-setting]]
  131. Static::
  132. Static settings can only be configured on an unstarted or shut down node using
  133. `elasticsearch.yml`.
  134. +
  135. Static settings must be set on every relevant node in the cluster.