| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | [[settings]]== Configuring ElasticsearchElasticsearch 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 (suchas `node.name` and paths), or settings which a node requires in order to beable to join a cluster, such as `cluster.name` and `network.host`.[[config-files-location]][discrete]=== Config files locationElasticsearch has three configuration files:* `elasticsearch.yml` for configuring Elasticsearch* `jvm.options` for configuring Elasticsearch JVM settings* `log4j2.properties` for configuring Elasticsearch loggingThese files are located in the config directory, whose default location dependson 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:[source,sh]-------------------------------ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch-------------------------------Alternatively, you can `export` the `ES_PATH_CONF` environment variable via thecommand 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 changedvia the `ES_PATH_CONF` environment variable, but note that setting this in yourshell is not sufficient. Instead, this variable 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 tochange the config directory location.[discrete]=== Config file formatThe configuration format is https://yaml.org/[YAML]. Here is anexample of changing the path of the data and logs directories:[source,yaml]--------------------------------------------------path:    data: /var/lib/elasticsearch    logs: /var/log/elasticsearch--------------------------------------------------Settings can also be flattened as follows:[source,yaml]--------------------------------------------------path.data: /var/lib/elasticsearchpath.logs: /var/log/elasticsearch--------------------------------------------------In YAML, you can format non-scalar values as sequences:[source,yaml]----discovery.seed_hosts:   - 192.168.1.10:9300   - 192.168.1.11   - seeds.mydomain.com----Though less common, you can also format non-scalar values as arrays:[source,yaml]----discovery.seed_hosts: ["192.168.1.10:9300", "192.168.1.11", "seeds.mydomain.com"]----[discrete]=== Environment variable substitutionEnvironment variables referenced with the `${...}` notation within theconfiguration file will be replaced with the value of the environmentvariable. For example:[source,yaml]--------------------------------------------------node.name:    ${HOSTNAME}network.host: ${ES_NETWORK_HOST}--------------------------------------------------Values for environment variables must be simple strings. Use a comma-separated string to provide values that Elasticsearch will parse as a list. For example, Elasticsearch will split the following string into a list of values for the `${HOSTNAME}` environment variable:[source,yaml]----export HOSTNAME=“host1,host2"----[discrete][[cluster-setting-types]]=== Cluster and node setting typesCluster and node settings can be categorized based on how they are configured:[[dynamic-cluster-setting]]Dynamic::+--You can configure and update dynamic settings on a running cluster using the<<cluster-update-settings,cluster update settings API>>. You can also configuredynamic settings locally on an unstarted or shut down node using`elasticsearch.yml`.Updates made using the cluster update settings API can be _persistent_, whichapply across cluster restarts, or _transient_, which reset after a clusterrestart. You can also reset transient or persistent settings by assigning thema `null` value using the API.If you configure the same setting using multiple methods, {es} applies thesettings in following order of precedence:1. Transient setting2. Persistent setting3. `elasticsearch.yml` setting4. Default setting valueFor example, you can apply a transient setting to override a persistent settingor `elasticsearch.yml` setting. However, a change to an `elasticsearch.yml`setting will not override a defined transient or persistent setting.TIP: It’s best to set dynamic, cluster-wide settings with the cluster updatesettings API and use `elasticsearch.yml` only for local configurations. Usingthe cluster update settings API ensures the setting is the same on all nodes. Ifyou accidentally configure different settings in `elasticsearch.yml` ondifferent nodes, it can be difficult to notice discrepancies.--[[static-cluster-setting]]Static::Static settings can only be configured on an unstarted or shut down node using`elasticsearch.yml`.+Static settings must be set on every relevant node in the cluster.
 |