configuration.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. You can configure and update dynamic settings on a running cluster using the
  74. <<cluster-update-settings,cluster update settings API>>.
  75. +
  76. You can also configure dynamic settings locally on an unstarted or shut down
  77. node using `elasticsearch.yml`.
  78. +
  79. TIP: It’s best to set dynamic, cluster-wide settings with the cluster update
  80. settings API and use `elasticsearch.yml` only for local configurations. Using
  81. the cluster update settings API ensures the setting is the same on all nodes. If
  82. you accidentally configure different settings in `elasticsearch.yml` on
  83. different nodes, it can be difficult to notice discrepancies.
  84. [[static-cluster-setting]]
  85. Static::
  86. Static settings can only be configured on an unstarted or shut down node using
  87. `elasticsearch.yml`.
  88. +
  89. Static settings must be set on every relevant node in the cluster.