Configuring Elasticsearchedit

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.

The configuration files should contain settings which are node-specific (such as and paths), or settings which a node requires in order to be able to join a cluster, such as and

Config files locationedit

Elasticsearch has three configuration files:

  • elasticsearch.yml for configuring Elasticsearch
  • jvm.options for configuring Elasticsearch JVM settings
  • for configuring Elasticsearch logging

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).

For the archive distributions, the config directory location defaults to $ES_HOME/config. The location of the config directory can be changed via the ES_PATH_CONF environment variable as follows:

ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch

Alternatively, you can export the ES_PATH_CONF environment variable via the 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 via the ES_PATH_CONF environment variable, but note that setting this in your 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 ES_PATH_CONF=/etc/elasticsearch entry in one of these files accordingly to change the config directory location.

Config file formatedit

The configuration format is YAML. Here is an example of changing the path of the data and logs directories:

    data: /var/lib/elasticsearch
    logs: /var/log/elasticsearch

Settings can also be flattened as follows: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

Environment variable substitutionedit

Environment variables referenced with the ${...} notation within the configuration file will be replaced with the value of the environment variable, for instance:    ${HOSTNAME} ${ES_NETWORK_HOST}

Prompting for settingsedit

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:

  name: ${prompt.text}

When starting Elasticsearch, you will be prompted to enter the actual value like so:

Enter value for []:

Elasticsearch will not start if ${prompt.text} or ${prompt.secret} is used in the settings and the process is run as a service or in the background.