configuration.asciidoc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. [[settings]]
  2. == Configuring Elasticsearch
  3. Elasticsearch 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. Elasticsearch has three configuration files:
  13. * `elasticsearch.yml` for configuring Elasticsearch
  14. * `jvm.options` for configuring Elasticsearch JVM settings
  15. * `log4j2.properties` for configuring Elasticsearch 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. [discrete]
  53. === Environment variable substitution
  54. Environment variables referenced with the `${...}` notation within the
  55. configuration file will be replaced with the value of the environment
  56. variable. For example:
  57. [source,yaml]
  58. --------------------------------------------------
  59. node.name: ${HOSTNAME}
  60. network.host: ${ES_NETWORK_HOST}
  61. --------------------------------------------------
  62. Values for environment variables must be simple strings. Use a comma-separated string to provide values that Elasticsearch will parse as a list. For example, Elasticsearch will split the following string into a list of values for the `${HOSTNAME}` environment variable:
  63. [source,yaml]
  64. ----
  65. export HOSTNAME=“host1,host2"
  66. ----
  67. [discrete]
  68. [[cluster-setting-types]]
  69. === Cluster and node setting types
  70. Cluster and node settings can be categorized based on how they are configured:
  71. [[dynamic-cluster-setting]]
  72. Dynamic::
  73. +
  74. --
  75. You can configure and update dynamic settings on a running cluster using the
  76. <<cluster-update-settings,cluster update settings API>>. You can also configure
  77. dynamic settings locally on an unstarted or shut down node using
  78. `elasticsearch.yml`.
  79. Updates made using the cluster update settings API can be _persistent_, which
  80. apply across cluster restarts, or _transient_, which reset after a cluster
  81. restart. You can also reset transient or persistent settings by assigning them
  82. a `null` value using the API.
  83. If you configure the same setting using multiple methods, {es} applies the
  84. settings in following order of precedence:
  85. 1. Transient setting
  86. 2. Persistent setting
  87. 3. `elasticsearch.yml` setting
  88. 4. Default setting value
  89. For example, you can apply a transient setting to override a persistent setting
  90. or `elasticsearch.yml` setting. However, a change to an `elasticsearch.yml`
  91. setting will not override a defined transient or persistent setting.
  92. TIP: It’s best to set dynamic, cluster-wide settings with the cluster update
  93. settings API and use `elasticsearch.yml` only for local configurations. Using
  94. the cluster update settings API ensures the setting is the same on all nodes. If
  95. you accidentally configure different settings in `elasticsearch.yml` on
  96. different nodes, it can be difficult to notice discrepancies.
  97. --
  98. [[static-cluster-setting]]
  99. Static::
  100. Static settings can only be configured on an unstarted or shut down node using
  101. `elasticsearch.yml`.
  102. +
  103. Static settings must be set on every relevant node in the cluster.