2016-04-03 10:09:24 -04:00
|
|
|
[[settings]]
|
|
|
|
== Configuring Elasticsearch
|
2014-06-12 07:56:06 -04:00
|
|
|
|
2016-04-03 10:09:24 -04:00
|
|
|
Elasticsearch ships with good defaults and requires very little configuration.
|
|
|
|
Most settings can be changed on a running cluster using the
|
|
|
|
<<cluster-update-settings>> API.
|
2013-10-17 05:54:36 -04:00
|
|
|
|
2016-04-03 10:09:24 -04:00
|
|
|
The configuration files should contain settings which are node-specific (such
|
|
|
|
as `node.name` and paths), or settings which a node requires in order to be
|
|
|
|
able to join a cluster, such as `cluster.name` and `network.host`.
|
2014-11-21 15:41:06 -05:00
|
|
|
|
2017-07-31 20:52:23 -04:00
|
|
|
[[config-files-location]]
|
2013-09-30 17:32:00 -04:00
|
|
|
[float]
|
2017-07-31 20:52:23 -04:00
|
|
|
=== Config files location
|
2014-05-02 04:44:26 -04:00
|
|
|
|
2017-07-31 20:52:23 -04:00
|
|
|
Elasticsearch has three configuration files:
|
2014-05-14 10:01:25 -04:00
|
|
|
|
2017-07-31 20:52:23 -04:00
|
|
|
* `elasticsearch.yml` for configuring Elasticsearch
|
|
|
|
* `jvm.options` for configuring Elasticsearch JVM settings
|
|
|
|
* `log4j2.properties` for configuring Elasticsearch logging
|
2014-05-14 10:01:25 -04:00
|
|
|
|
2017-07-31 20:52:23 -04:00
|
|
|
These files are located in the config directory, whose default location depends
|
|
|
|
on whether or not the installation is from an archive distribution (`tar.gz` or
|
|
|
|
`zip`) or a package distribution (Debian or RPM packages).
|
2014-05-14 10:01:25 -04:00
|
|
|
|
2017-07-31 20:52:23 -04:00
|
|
|
For the archive distributions, the config directory location defaults to
|
|
|
|
`$ES_HOME/config`. The location of the config directory can be changed via the
|
2017-08-14 17:19:06 -04:00
|
|
|
`ES_PATH_CONF` environment variable as follows:
|
2014-05-14 10:01:25 -04:00
|
|
|
|
|
|
|
[source,sh]
|
2016-04-03 10:09:24 -04:00
|
|
|
-------------------------------
|
2017-08-14 17:19:06 -04:00
|
|
|
ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch
|
2016-04-03 10:09:24 -04:00
|
|
|
-------------------------------
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2017-08-14 17:19:06 -04:00
|
|
|
Alternatively, you can `export` the `ES_PATH_CONF` environment variable via the
|
2017-07-31 20:52:23 -04:00
|
|
|
command line or via your shell profile.
|
|
|
|
|
|
|
|
For the package distributions, the config directory location defaults to
|
|
|
|
`/etc/elasticsearch`. The location of the config directory can also be changed
|
2017-08-14 17:19:06 -04:00
|
|
|
via the `ES_PATH_CONF` environment variable, but note that setting this in your
|
2017-07-31 20:52:23 -04:00
|
|
|
shell is not sufficient. Instead, this variabled is sourced from
|
|
|
|
`/etc/default/elasticsearch` (for the Debian package) and
|
|
|
|
`/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the
|
2017-08-14 17:19:06 -04:00
|
|
|
`ES_PATH_CONF=/etc/elasticsearch` entry in one of these files accordingly to
|
|
|
|
change the config directory location.
|
2017-07-31 20:52:23 -04:00
|
|
|
|
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
[float]
|
2016-04-03 10:09:24 -04:00
|
|
|
=== Config file format
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
The configuration format is http://www.yaml.org/[YAML]. Here is an
|
2016-04-03 10:09:24 -04:00
|
|
|
example of changing the path of the data and logs directories:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
path:
|
2016-04-03 10:09:24 -04:00
|
|
|
data: /var/lib/elasticsearch
|
2016-05-12 16:42:27 -04:00
|
|
|
logs: /var/log/elasticsearch
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
2016-04-03 10:09:24 -04:00
|
|
|
Settings can also be flattened as follows:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-04-03 10:09:24 -04:00
|
|
|
path.data: /var/lib/elasticsearch
|
2016-05-12 16:42:27 -04:00
|
|
|
path.logs: /var/log/elasticsearch
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[float]
|
2017-05-19 10:49:56 -04:00
|
|
|
=== Environment variable substitution
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2016-04-03 10:09:24 -04:00
|
|
|
Environment variables referenced with the `${...}` notation within the
|
|
|
|
configuration file will be replaced with the value of the environment
|
|
|
|
variable, for instance:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2013-10-17 05:54:36 -04:00
|
|
|
[source,yaml]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-04-03 10:09:24 -04:00
|
|
|
node.name: ${HOSTNAME}
|
|
|
|
network.host: ${ES_NETWORK_HOST}
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[float]
|
2016-04-03 10:09:24 -04:00
|
|
|
=== Prompting for settings
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2016-04-03 10:09:24 -04:00
|
|
|
For settings that you do not wish to store in the configuration file, you can
|
|
|
|
use the value `${prompt.text}` or `${prompt.secret}` and start Elasticsearch
|
|
|
|
in the foreground. `${prompt.secret}` has echoing disabled so that the value
|
|
|
|
entered will not be shown in your terminal; `${prompt.text}` will allow you to
|
|
|
|
see the value as you type it in. For example:
|
2015-04-30 13:14:05 -04:00
|
|
|
|
|
|
|
[source,yaml]
|
|
|
|
--------------------------------------------------
|
|
|
|
node:
|
2015-06-06 10:41:07 -04:00
|
|
|
name: ${prompt.text}
|
2015-04-30 13:14:05 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
2016-04-03 10:09:24 -04:00
|
|
|
When starting Elasticsearch, you will be prompted to enter the actual value
|
|
|
|
like so:
|
2015-04-30 13:14:05 -04:00
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
--------------------------------------------------
|
|
|
|
Enter value for [node.name]:
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2015-06-06 10:41:07 -04:00
|
|
|
NOTE: Elasticsearch will not start if `${prompt.text}` or `${prompt.secret}`
|
2015-04-30 13:14:05 -04:00
|
|
|
is used in the settings and the process is run as a service or in the background.
|
|
|
|
|