configuration.asciidoc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. [[setup-configuration]]
  2. == Configuration
  3. [float]
  4. === Environment Variables
  5. Within the scripts, ElasticSearch comes with built in `JAVA_OPTS` passed
  6. to the JVM started. The most important setting for that is the `-Xmx` to
  7. control the maximum allowed memory for the process, and `-Xms` to
  8. control the minimum allocated memory for the process (_in general, the
  9. more memory allocated to the process, the better_).
  10. Most times it is better to leave the default `JAVA_OPTS` as they are,
  11. and use the `ES_JAVA_OPTS` environment variable in order to set / change
  12. JVM settings or arguments.
  13. The `ES_HEAP_SIZE` environment variable allows to set the heap memory
  14. that will be allocated to elasticsearch java process. It will allocate
  15. the same value to both min and max values, though those can be set
  16. explicitly (not recommended) by setting `ES_MIN_MEM` (defaults to
  17. `256m`), and `ES_MAX_MEM` (defaults to `1gb`).
  18. It is recommended to set the min and max memory to the same value, and
  19. enable <<setup-configuration-memory,`mlockall`>>.
  20. [float]
  21. [[system]]
  22. === System Configuration
  23. [float]
  24. [[file-descriptors]]
  25. ==== File Descriptors
  26. Make sure to increase the number of open files descriptors on the
  27. machine (or for the user running elasticsearch). Setting it to 32k or
  28. even 64k is recommended.
  29. In order to test how many open files the process can open, start it with
  30. `-Des.max-open-files` set to `true`. This will print the number of open
  31. files the process can open on startup.
  32. ["float",id="setup-configuration-memory"]
  33. [[memory]]
  34. ==== Memory Settings
  35. There is an option to use
  36. http://opengroup.org/onlinepubs/007908799/xsh/mlockall.html[mlockall] to
  37. try to lock the process address space so it won't be swapped. For this
  38. to work, the `bootstrap.mlockall` should be set to `true` and it is
  39. recommended to set both the min and max memory allocation to be the
  40. same. Note: This option is only available on Linux/Unix operating
  41. systems.
  42. In order to see if this works or not, set the `common.jna` logging to
  43. DEBUG level. A solution to "Unknown mlockall error 0" can be to set
  44. `ulimit -l unlimited`.
  45. Note, `mlockall` might cause the JVM or shell
  46. session to exit if it fails to allocate the memory (because not enough
  47. memory is available on the machine).
  48. [float]
  49. [[settings]]
  50. === Elasticsearch Settings
  51. *elasticsearch* configuration files can be found under `ES_HOME/config`
  52. folder. The folder comes with two files, the `elasticsearch.yml` for
  53. configuring ElasticSearch different
  54. <<modules,modules>>, and `logging.yml` for
  55. configuring the ElasticSearch logging.
  56. The configuration format is http://www.yaml.org/[YAML]. Here is an
  57. example of changing the address all network based modules will use to
  58. bind and publish to:
  59. [source,js]
  60. --------------------------------------------------
  61. network :
  62. host : 10.0.0.4
  63. --------------------------------------------------
  64. *elasticsearch* configuration files can be found under `ES_HOME/config`
  65. folder. The folder comes with two files, the `elasticsearch.yml` for
  66. configuring ElasticSearch different <<modules,modules>>, and `logging.yml`
  67. for configuring the ElasticSearch logging.
  68. [float]
  69. [[paths]]
  70. ==== Paths
  71. In production use, you will almost certainly want to change paths for
  72. data and log files:
  73. [source,js]
  74. --------------------------------------------------
  75. path:
  76. logs: /var/log/elasticsearch
  77. data: /var/data/elasticsearch
  78. --------------------------------------------------
  79. [float]
  80. [[cluster-name]]
  81. ==== Cluster name
  82. Also, don't forget to give your production cluster a name, which is used
  83. to discover and auto-join other nodes:
  84. [source,js]
  85. --------------------------------------------------
  86. cluster:
  87. name: <NAME OF YOUR CLUSTER>
  88. --------------------------------------------------
  89. [float]
  90. [[node-name]]
  91. ==== Node name
  92. You may also want to change the default node name for each node to
  93. something like the display hostname. By default ElasticSearch will
  94. randomly pick a Marvel character name from a list of around 3000 names
  95. when your node starts up.
  96. [source,js]
  97. --------------------------------------------------
  98. node:
  99. name: <NAME OF YOUR NODE>
  100. --------------------------------------------------
  101. Internally, all settings are collapsed into "namespaced" settings. For
  102. example, the above gets collapsed into `network.host`. This means that
  103. its easy to support other configuration formats, for example,
  104. http://www.json.org[JSON]. If JSON is a preferred configuration format,
  105. simply rename the `elasticsearch.yml` file to `elasticsearch.json` and
  106. add:
  107. [float]
  108. [[styles]]
  109. ==== Configuration styles
  110. [source,js]
  111. --------------------------------------------------
  112. {
  113. "network" : {
  114. "host" : "10.0.0.4"
  115. }
  116. }
  117. --------------------------------------------------
  118. It also means that its easy to provide the settings externally either
  119. using the `ES_JAVA_OPTS` or as parameters to the `elasticsearch`
  120. command, for example:
  121. [source,js]
  122. --------------------------------------------------
  123. $ elasticsearch -f -Des.network.host=10.0.0.4
  124. --------------------------------------------------
  125. Another option is to set `es.default.` prefix instead of `es.` prefix,
  126. which means the default setting will be used only if not explicitly set
  127. in the configuration file.
  128. Another option is to use the `${...}` notation within the configuration
  129. file which will resolve to an environment setting, for example:
  130. [source,js]
  131. --------------------------------------------------
  132. {
  133. "network" : {
  134. "host" : "${ES_NET_HOST}"
  135. }
  136. }
  137. --------------------------------------------------
  138. The location of the configuration file can be set externally using a
  139. system property:
  140. [source,js]
  141. --------------------------------------------------
  142. $ elasticsearch -f -Des.config=/path/to/config/file
  143. --------------------------------------------------
  144. [float]
  145. [[index-settings]]
  146. === Index Settings
  147. Indices created within the cluster can provide their own settings. For
  148. example, the following creates an index with memory based storage
  149. instead of the default file system based one (the format can be either
  150. YAML or JSON):
  151. [source,js]
  152. --------------------------------------------------
  153. $ curl -XPUT http://localhost:9200/kimchy/ -d \
  154. '
  155. index :
  156. store:
  157. type: memory
  158. '
  159. --------------------------------------------------
  160. Index level settings can be set on the node level as well, for example,
  161. within the `elasticsearch.yml` file, the following can be set:
  162. [source,js]
  163. --------------------------------------------------
  164. index :
  165. store:
  166. type: memory
  167. --------------------------------------------------
  168. This means that every index that gets created on the specific node
  169. started with the mentioned configuration will store the index in memory
  170. *unless the index explicitly sets it*. In other words, any index level
  171. settings override what is set in the node configuration. Of course, the
  172. above can also be set as a "collapsed" setting, for example:
  173. [source,js]
  174. --------------------------------------------------
  175. $ elasticsearch -f -Des.index.store.type=memory
  176. --------------------------------------------------
  177. All of the index level configuration can be found within each
  178. <<index-modules,index module>>.
  179. [float]
  180. [[logging]]
  181. === Logging
  182. ElasticSearch uses an internal logging abstraction and comes, out of the
  183. box, with http://logging.apache.org/log4j/[log4j]. It tries to simplify
  184. log4j configuration by using http://www.yaml.org/[YAML] to configure it,
  185. and the logging configuration file is `config/logging.yml` file.