configuration.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. You can configure and update dynamic settings on a running cluster using the
  89. <<cluster-update-settings,cluster update settings API>>. You can also configure
  90. dynamic settings locally on an unstarted or shut down node using
  91. `elasticsearch.yml`.
  92. Updates made using the cluster update settings API can be _persistent_, which
  93. apply across cluster restarts, or _transient_, which reset after a cluster
  94. restart. You can also reset transient or persistent settings by assigning them
  95. a `null` value using the API.
  96. If you configure the same setting using multiple methods, {es} applies the
  97. settings in following order of precedence:
  98. 1. Transient setting
  99. 2. Persistent setting
  100. 3. `elasticsearch.yml` setting
  101. 4. Default setting value
  102. For example, you can apply a transient setting to override a persistent setting
  103. or `elasticsearch.yml` setting. However, a change to an `elasticsearch.yml`
  104. setting will not override a defined transient or persistent setting.
  105. [TIP]
  106. ====
  107. If you use {ess}, use the {cloud}/ec-add-user-settings.html[user settings]
  108. feature to configure all cluster settings. This method lets {ess} automatically
  109. reject unsafe settings that could break your cluster.
  110. If you run {es} on your own hardware, use the <<cluster-update-settings,cluster
  111. update settings API>> to configure dynamic cluster settings. Only use
  112. `elasticsearch.yml` for static cluster settings and node settings. The API
  113. doesn't require a restart and ensures a setting's value is the same on all
  114. nodes.
  115. ====
  116. include::{es-repo-dir}/cluster/update-settings.asciidoc[tag=transient-settings-warning]
  117. --
  118. [[static-cluster-setting]]
  119. Static::
  120. Static settings can only be configured on an unstarted or shut down node using
  121. `elasticsearch.yml`.
  122. +
  123. Static settings must be set on every relevant node in the cluster.