Can you set ES node name to same as the machine hostname?

(Matt Stibbs) #1

Is it possible to use environment variables or similar to automatically set an Elasticsearch node name to the hostname of the machine?

i.e. if a machine is called ES1, the ES node name would also be ES1 without having to configure it in elasticsearch.yml manually?

Can you set Kibana server name to same as the machine hostname?
(Lee Hinman) #2

Yes, you can substitute any environment variable in elasticsearch.yml by using ${...} notation, such as: ${HOSTNAME}

(Matt Stibbs) #3

Perfect - thank you. I tried to find something about this in the documentation but clearly wasn't looking in the right place!

(Matt Stibbs) #5

I found that I had to add the following line to /etc/init.d/elasticsearch script (on Ubuntu):

export NODENAME=`hostname`

N.B. Important that you use back ticks for this

and then update elasticsearch.yml to: ${NODENAME}

(Mark Walkom) #6

I wouldn't edit the init script, this can change between versions and you might find an upgrade will break it.

(Matt Stibbs) #7

Thanks for the advice @warkolm - I'll look into alternative ways of setting the env variable!

(system) #8