2013-08-28 19:24:34 -04:00
|
|
|
[[setup-configuration]]
|
|
|
|
== Configuration
|
|
|
|
|
|
|
|
[float]
|
|
|
|
=== Environment Variables
|
|
|
|
|
2014-01-06 15:58:46 -05:00
|
|
|
Within the scripts, Elasticsearch comes with built in `JAVA_OPTS` passed
|
2013-08-28 19:24:34 -04:00
|
|
|
to the JVM started. The most important setting for that is the `-Xmx` to
|
|
|
|
control the maximum allowed memory for the process, and `-Xms` to
|
|
|
|
control the minimum allocated memory for the process (_in general, the
|
|
|
|
more memory allocated to the process, the better_).
|
|
|
|
|
|
|
|
Most times it is better to leave the default `JAVA_OPTS` as they are,
|
|
|
|
and use the `ES_JAVA_OPTS` environment variable in order to set / change
|
|
|
|
JVM settings or arguments.
|
|
|
|
|
|
|
|
The `ES_HEAP_SIZE` environment variable allows to set the heap memory
|
|
|
|
that will be allocated to elasticsearch java process. It will allocate
|
|
|
|
the same value to both min and max values, though those can be set
|
|
|
|
explicitly (not recommended) by setting `ES_MIN_MEM` (defaults to
|
|
|
|
`256m`), and `ES_MAX_MEM` (defaults to `1gb`).
|
|
|
|
|
|
|
|
It is recommended to set the min and max memory to the same value, and
|
|
|
|
enable <<setup-configuration-memory,`mlockall`>>.
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[system]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== System Configuration
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[file-descriptors]]
|
2013-08-28 19:24:34 -04:00
|
|
|
==== File Descriptors
|
|
|
|
|
|
|
|
Make sure to increase the number of open files descriptors on the
|
|
|
|
machine (or for the user running elasticsearch). Setting it to 32k or
|
|
|
|
even 64k is recommended.
|
|
|
|
|
|
|
|
In order to test how many open files the process can open, start it with
|
|
|
|
`-Des.max-open-files` set to `true`. This will print the number of open
|
|
|
|
files the process can open on startup.
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
Alternatively, you can retrieve the `max_file_descriptors` for each node
|
|
|
|
using the <<cluster-nodes-info>> API, with:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
curl localhost:9200/_nodes/process?pretty
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
|
2013-09-30 17:32:00 -04:00
|
|
|
[float]
|
|
|
|
[[setup-configuration-memory]]
|
2013-08-28 19:24:34 -04:00
|
|
|
==== Memory Settings
|
|
|
|
|
|
|
|
There is an option to use
|
|
|
|
http://opengroup.org/onlinepubs/007908799/xsh/mlockall.html[mlockall] to
|
|
|
|
try to lock the process address space so it won't be swapped. For this
|
|
|
|
to work, the `bootstrap.mlockall` should be set to `true` and it is
|
|
|
|
recommended to set both the min and max memory allocation to be the
|
|
|
|
same. Note: This option is only available on Linux/Unix operating
|
|
|
|
systems.
|
|
|
|
|
|
|
|
In order to see if this works or not, set the `common.jna` logging to
|
|
|
|
DEBUG level. A solution to "Unknown mlockall error 0" can be to set
|
|
|
|
`ulimit -l unlimited`.
|
|
|
|
|
|
|
|
Note, `mlockall` might cause the JVM or shell
|
|
|
|
session to exit if it fails to allocate the memory (because not enough
|
|
|
|
memory is available on the machine).
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[settings]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Elasticsearch Settings
|
|
|
|
|
|
|
|
*elasticsearch* configuration files can be found under `ES_HOME/config`
|
|
|
|
folder. The folder comes with two files, the `elasticsearch.yml` for
|
2014-01-06 15:58:46 -05:00
|
|
|
configuring Elasticsearch different
|
2013-08-28 19:24:34 -04:00
|
|
|
<<modules,modules>>, and `logging.yml` for
|
2014-01-06 15:58:46 -05:00
|
|
|
configuring the Elasticsearch logging.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
The configuration format is http://www.yaml.org/[YAML]. Here is an
|
|
|
|
example of changing the address all network based modules will use to
|
|
|
|
bind and publish to:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
network :
|
|
|
|
host : 10.0.0.4
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[paths]]
|
2013-08-28 19:24:34 -04:00
|
|
|
==== Paths
|
|
|
|
|
|
|
|
In production use, you will almost certainly want to change paths for
|
|
|
|
data and log files:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
path:
|
|
|
|
logs: /var/log/elasticsearch
|
|
|
|
data: /var/data/elasticsearch
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[cluster-name]]
|
2013-08-28 19:24:34 -04:00
|
|
|
==== Cluster name
|
|
|
|
|
|
|
|
Also, don't forget to give your production cluster a name, which is used
|
|
|
|
to discover and auto-join other nodes:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
cluster:
|
|
|
|
name: <NAME OF YOUR CLUSTER>
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[node-name]]
|
2013-08-28 19:24:34 -04:00
|
|
|
==== Node name
|
|
|
|
|
|
|
|
You may also want to change the default node name for each node to
|
2014-01-06 15:58:46 -05:00
|
|
|
something like the display hostname. By default Elasticsearch will
|
2013-08-28 19:24:34 -04:00
|
|
|
randomly pick a Marvel character name from a list of around 3000 names
|
|
|
|
when your node starts up.
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
node:
|
|
|
|
name: <NAME OF YOUR NODE>
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Internally, all settings are collapsed into "namespaced" settings. For
|
2013-12-22 13:32:09 -05:00
|
|
|
example, the above gets collapsed into `node.name`. This means that
|
2013-08-28 19:24:34 -04:00
|
|
|
its easy to support other configuration formats, for example,
|
|
|
|
http://www.json.org[JSON]. If JSON is a preferred configuration format,
|
|
|
|
simply rename the `elasticsearch.yml` file to `elasticsearch.json` and
|
|
|
|
add:
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[styles]]
|
2013-08-28 19:24:34 -04:00
|
|
|
==== Configuration styles
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"network" : {
|
|
|
|
"host" : "10.0.0.4"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
It also means that its easy to provide the settings externally either
|
|
|
|
using the `ES_JAVA_OPTS` or as parameters to the `elasticsearch`
|
|
|
|
command, for example:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,sh]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2013-12-15 14:29:11 -05:00
|
|
|
$ elasticsearch -Des.network.host=10.0.0.4
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Another option is to set `es.default.` prefix instead of `es.` prefix,
|
|
|
|
which means the default setting will be used only if not explicitly set
|
|
|
|
in the configuration file.
|
|
|
|
|
|
|
|
Another option is to use the `${...}` notation within the configuration
|
|
|
|
file which will resolve to an environment setting, for example:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"network" : {
|
|
|
|
"host" : "${ES_NET_HOST}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The location of the configuration file can be set externally using a
|
|
|
|
system property:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,sh]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2013-12-15 14:29:11 -05:00
|
|
|
$ elasticsearch -Des.config=/path/to/config/file
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[float]
|
2013-09-30 17:32:00 -04:00
|
|
|
[[configuration-index-settings]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Index Settings
|
|
|
|
|
|
|
|
Indices created within the cluster can provide their own settings. For
|
|
|
|
example, the following creates an index with memory based storage
|
|
|
|
instead of the default file system based one (the format can be either
|
|
|
|
YAML or JSON):
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,sh]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
$ curl -XPUT http://localhost:9200/kimchy/ -d \
|
|
|
|
'
|
|
|
|
index :
|
|
|
|
store:
|
|
|
|
type: memory
|
|
|
|
'
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Index level settings can be set on the node level as well, for example,
|
|
|
|
within the `elasticsearch.yml` file, the following can be set:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
index :
|
|
|
|
store:
|
|
|
|
type: memory
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
This means that every index that gets created on the specific node
|
|
|
|
started with the mentioned configuration will store the index in memory
|
|
|
|
*unless the index explicitly sets it*. In other words, any index level
|
|
|
|
settings override what is set in the node configuration. Of course, the
|
|
|
|
above can also be set as a "collapsed" setting, for example:
|
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,sh]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2013-12-15 14:29:11 -05:00
|
|
|
$ elasticsearch -Des.index.store.type=memory
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
All of the index level configuration can be found within each
|
|
|
|
<<index-modules,index module>>.
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[logging]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Logging
|
|
|
|
|
2014-01-06 15:58:46 -05:00
|
|
|
Elasticsearch uses an internal logging abstraction and comes, out of the
|
2013-08-28 19:24:34 -04:00
|
|
|
box, with http://logging.apache.org/log4j/[log4j]. It tries to simplify
|
|
|
|
log4j configuration by using http://www.yaml.org/[YAML] to configure it,
|
|
|
|
and the logging configuration file is `config/logging.yml` file.
|