configuration.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. [float]
  10. === Config file location
  11. Elasticsearch has two configuration files:
  12. * `elasticsearch.yml` for configuring Elasticsearch, and
  13. * `logging.yml` for configuring Elasticsearch logging.
  14. These files are located in the config directory, whose location defaults to
  15. `$ES_HOME/config/`. The Debian and RPM packages set the config directory
  16. location to `/etc/elasticsearch/`.
  17. The location of the config directory can be changed with the `path.conf`
  18. setting, as follows:
  19. [source,sh]
  20. -------------------------------
  21. ./bin/elasticsearch -Epath.conf=/path/to/my/config/
  22. -------------------------------
  23. [float]
  24. === Config file format
  25. The configuration format is http://www.yaml.org/[YAML]. Here is an
  26. example of changing the path of the data and logs directories:
  27. [source,yaml]
  28. --------------------------------------------------
  29. path:
  30. data: /var/lib/elasticsearch
  31. logs: /var/log/elasticsearch
  32. --------------------------------------------------
  33. Settings can also be flattened as follows:
  34. [source,yaml]
  35. --------------------------------------------------
  36. path.data: /var/lib/elasticsearch
  37. path.logs: /var/log/elasticsearch
  38. --------------------------------------------------
  39. [float]
  40. === Environment variable subsitution
  41. Environment variables referenced with the `${...}` notation within the
  42. configuration file will be replaced with the value of the environment
  43. variable, for instance:
  44. [source,yaml]
  45. --------------------------------------------------
  46. node.name: ${HOSTNAME}
  47. network.host: ${ES_NETWORK_HOST}
  48. --------------------------------------------------
  49. [float]
  50. === Prompting for settings
  51. For settings that you do not wish to store in the configuration file, you can
  52. use the value `${prompt.text}` or `${prompt.secret}` and start Elasticsearch
  53. in the foreground. `${prompt.secret}` has echoing disabled so that the value
  54. entered will not be shown in your terminal; `${prompt.text}` will allow you to
  55. see the value as you type it in. For example:
  56. [source,yaml]
  57. --------------------------------------------------
  58. node:
  59. name: ${prompt.text}
  60. --------------------------------------------------
  61. When starting Elasticsearch, you will be prompted to enter the actual value
  62. like so:
  63. [source,sh]
  64. --------------------------------------------------
  65. Enter value for [node.name]:
  66. --------------------------------------------------
  67. NOTE: Elasticsearch will not start if `${prompt.text}` or `${prompt.secret}`
  68. is used in the settings and the process is run as a service or in the background.
  69. [float]
  70. === Setting default settings
  71. New default settings may be specified on the command line using the
  72. `default.` prefix. This will specify a value that will be used by
  73. default unless another value is specified in the config file.
  74. For instance, if Elasticsearch is started as follows:
  75. [source,sh]
  76. ---------------------------
  77. ./bin/elasticsearch -Edefault.node.name=My_Node
  78. ---------------------------
  79. the value for `node.name` will be `My_Node`, unless it is overwritten on the
  80. command line with `es.node.name` or in the config file with `node.name`.
  81. [float]
  82. [[logging]]
  83. == Logging configuration
  84. Elasticsearch uses an internal logging abstraction and comes, out of the
  85. box, with http://logging.apache.org/log4j/1.2/[log4j]. It tries to simplify
  86. log4j configuration by using http://www.yaml.org/[YAML] to configure it,
  87. and the logging configuration file is `config/logging.yml`. The
  88. http://en.wikipedia.org/wiki/JSON[JSON] and
  89. http://en.wikipedia.org/wiki/.properties[properties] formats are also
  90. supported. Multiple configuration files can be loaded, in which case they will
  91. get merged, as long as they start with the `logging.` prefix and end with one
  92. of the supported suffixes (either `.yml`, `.yaml`, `.json` or `.properties`).
  93. The logger section contains the java packages and their corresponding log
  94. level, where it is possible to omit the `org.elasticsearch` prefix. The
  95. appender section contains the destinations for the logs. Extensive information
  96. on how to customize logging and all the supported appenders can be found on
  97. the http://logging.apache.org/log4j/1.2/manual.html[log4j documentation].
  98. Additional Appenders and other logging classes provided by
  99. http://logging.apache.org/log4j/extras/[log4j-extras] are also available,
  100. out of the box.
  101. [float]
  102. [[deprecation-logging]]
  103. === Deprecation logging
  104. In addition to regular logging, Elasticsearch allows you to enable logging
  105. of deprecated actions. For example this allows you to determine early, if
  106. you need to migrate certain functionality in the future. By default,
  107. deprecation logging is disabled. You can enable it in the `config/logging.yml`
  108. file by setting the deprecation log level to `DEBUG`.
  109. [source,yaml]
  110. --------------------------------------------------
  111. deprecation: DEBUG, deprecation_log_file
  112. --------------------------------------------------
  113. This will create a daily rolling deprecation log file in your log directory.
  114. Check this file regularly, especially when you intend to upgrade to a new
  115. major version.