How to Specifying ES option via Shell environment variables for

Hello. I'm using ES 2.3.2

I've decided to use Shell Env. Variables in elasticsearch.yml because I want to maintain ONLY 1 elasticsearch.yml file even though I have many type of nodes in many clusters.

Most of configs are easy to use shell variables. But I turned out that is weird.

original elasticsearch.yml ["host1", "host2", "host3"]

First attempt

I've changed like this: [${UNICAST_HOSTS}]

And in the shell

export UNICAST_HOSTS='"host1", "host2", "host3"'

But I got an error (Maybe Invalid Placeholder? Sorry. I can't remember the exact error message).

Second attemp

  • elasticsearch.yml: ${UNICAST_HOSTS}
  • shell: export UNICAST_HOSTS='["host1", "host2", "host3"']

I got an error as well.

Final Solution

After several trials and errors, I've found that following configuration worked!

  • elasticsearch.yml: ${UNICAST_HOSTS}
  • shell: export UNICAST_HOSTS="host1, host2, host3"

It works fine. But where have [, ] gone? Is above configuration is correct? It would be happy if someone tell me "YES" or "NO". I'm not certain because I can't find any authorized documentation.

Hi @Brad_Jungsu_Heo

As far as I can see, the configuration is correct. You can add the following line to config/logging.yml: DEBUG

This enables debugging logging in the relevant module. On startup you will then see the following line:

[2016-07-27 13:46:52,028][DEBUG][] [-96ewfK] using initial hosts [host1, host2, host3], with concurrent_connects [10]

If this would not get parsed as a list and instead resolved as one host, you should see exceptions traces like this one on startup (which you obviously don't see):

Error injecting constructor, java.lang.IllegalArgumentException: Failed to resolve address for [host1, host2, host3]
  at<init>(Unknown Source)
  while locating
  while locating annotated with @org.elasticsearch.common.inject.multibindings.Element(setName=,uniqueId=1)
  at _unknown_
  while locating java.util.Set<>
    for parameter 1 at<init>(Unknown Source)
  while locating
    for parameter 5 at org.elasticsearch.discovery.zen.ZenDiscovery.<init>(Unknown Source)
  while locating org.elasticsearch.discovery.zen.ZenDiscovery
  while locating org.elasticsearch.discovery.Discovery
Caused by: java.lang.IllegalArgumentException: Failed to resolve address for [host1, host2, host3]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.lang.reflect.Constructor.newInstance(
    at [...]
Caused by: host1, host2, host3
    at org.elasticsearch.transport.TcpTransport.parse(
    at org.elasticsearch.transport.TcpTransport.addressesFromString(
    at org.elasticsearch.transport.TransportService.addressesFromString(
    ... 60 more

Once more: This was just a hypothetical example what would happen if Elasticsearch were not able to resolve this correctly.


Hi @danielmitterdorfer

Thank you so much!