# Possible to make ES Node Name same as Hostname?

**URL:** <https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988>\
**Category:** Elasticsearch\
**Created:** [December 21, 2013, 11:51pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988 "2013-12-21T23:51:33Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 21, 2013, 11:51pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/1 "2013-12-21T23:51:33Z")

</div>

System:  
Java openJDK 1.7  
elasticsearch 0.90.7

Following some old instructions, I modified  
/etc/sysconfig/elasticsearch  
ES\_JAVA\_OPTS="-Des.node.name=$(name -n cut -d'.' -f1)"

But, that crashes the elasticsearch service on start.  
I've tried the entry both with and without the double-quotes.

Commenting out the entry restores the elasticsearch functionality so it  
starts up without error again.

At the moment, it looks like Elasticsearch might be using only a randomly  
generated string to identify Elasticsearch nodes in a cluster.  
Elasticsearch-head appears to be assigning random "friendly names" to each  
node, but for consistency from session it would be far preferable for the  
Elasticsearch Node Name to be the same as the Hostname of the machine.

Am hoping this is not a problem with openJDK and would have to install  
Oracle Java instead (would be somewhat surprising if this would be a cause).

Thx,  
TS

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b1d601c0-95c7-475c-9c40-1814aa316843%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b1d601c0-95c7-475c-9c40-1814aa316843%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [December 22, 2013, 2:02am UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/2 "2013-12-22T02:02:23Z")

</div>

elasticsearch config file supports environment variables (and java system  
properties) substitution

for example (elasticsearch.yml):  
_node.name: ${name}_

_${name}_ will be replaced with environment variable (export  
name=) or system property (ES\_JAVA\_OPTS="-Dname=")

On Saturday, December 21, 2013 11:51:33 PM UTC, Tony Su wrote:

> System:  
> Java openJDK 1.7  
> elasticsearch 0.90.7
> 
> Following some old instructions, I modified  
> /etc/sysconfig/elasticsearch  
> ES\_JAVA\_OPTS="-Des.node.name=$(name -n cut -d'.' -f1)"
> 
> But, that crashes the elasticsearch service on start.  
> I've tried the entry both with and without the double-quotes.
> 
> Commenting out the entry restores the elasticsearch functionality so it  
> starts up without error again.
> 
> At the moment, it looks like Elasticsearch might be using only a randomly  
> generated string to identify Elasticsearch nodes in a cluster.  
> Elasticsearch-head appears to be assigning random "friendly names" to each  
> node, but for consistency from session it would be far preferable for the  
> Elasticsearch Node Name to be the same as the Hostname of the machine.
> 
> Am hoping this is not a problem with openJDK and would have to install  
> Oracle Java instead (would be somewhat surprising if this would be a cause).
> 
> Thx,  
> TS

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/557510ac-573f-46fd-867a-af555dad03c5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/557510ac-573f-46fd-867a-af555dad03c5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 22, 2013, 12:27pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/3 "2013-12-22T12:27:55Z")

</div>

On Linux/Solaris:

./bin/elasticsearch -Des.node.name="`hostname`"

or

ES\_JAVA\_OPTS="-Des.node.name=`hostname`" ./bin/elasticsearch

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoErnVFf\_SFswaA13hfs5qJ-UjPj8Rvg%2B7H%3DNMFg13Sc3A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoErnVFf_SFswaA13hfs5qJ-UjPj8Rvg%2B7H%3DNMFg13Sc3A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 22, 2013, 9:41pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/4 "2013-12-22T21:41:13Z")

</div>

Thx jorg, unfortunately your suggestions only configure actual strings, like my original example I'm hoping to automatically retrieve and insert the hostname of the machine. BTW if your suggestion is used in a config I've determined the "./bin/elasticsearch" should be omitted.

Karol,  
That looks closer to what I'm looking for but I'm uncertain if the variable can be setup at the beginning of the config file or can somehow be run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as a variable when defining java variables, eg in a profile? I'm also surprised by your use of angle brackets, should they be used as you describe or do they only represent a general grouping of the statement?

Thx,  
Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/01329950-5594-4d00-834f-729bd8f3a5a1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01329950-5594-4d00-834f-729bd8f3a5a1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 22, 2013, 10:38pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/5 "2013-12-22T22:38:55Z")

</div>

You can easily use ES\_JAVA\_OPTS in your favorite startup script, for  
automatic retrieving and inserting the hostname.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEbqKN-G\_b4dH73WNMWZPrfv3zKysAhrmEWT3w\_mSuFQg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEbqKN-G_b4dH73WNMWZPrfv3zKysAhrmEWT3w_mSuFQg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [December 23, 2013, 12:53am UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/6 "2013-12-23T00:53:48Z")

</div>

Take a look at default elasticsearch.yml:  
[https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
especially this part:

# Any element in the configuration can be replaced with environment variables

# by placing them in ${...} notation. For example:

# 

# node.rack: ${RACK\_ENV\_VAR}

so for example to accomplish this using environment variables:

- edit elasticsearch.yml:  
node.name: ${NAME}

- create custom bash script:  
#!/bin/bash

instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script

On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:

> Thx jorg, unfortunately your suggestions only configure actual strings,  
> like my original example I'm hoping to automatically retrieve and insert  
> the hostname of the machine. BTW if your suggestion is used in a config  
> I've determined the "./bin/elasticsearch" should be omitted.
> 
> Karol,  
> That looks closer to what I'm looking for but I'm uncertain if the  
> variable can be setup at the beginning of the config file or can somehow be  
> run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> a variable when defining java variables, eg in a profile? I'm also  
> surprised by your use of angle brackets, should they be used as you  
> describe or do they only represent a general grouping of the statement?
> 
> Thx,  
> Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9f4adf4a-2d14-4605-be58-112d39e5d8ae%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f4adf4a-2d14-4605-be58-112d39e5d8ae%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 23, 2013, 9:52pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/7 "2013-12-23T21:52:40Z")

</div>

After considering this post,  
I successfully created an environmental variable by adding to the bash  
profile file (actually on the openSUSE I'm running, I created a file  
/etc/profile.local which contains system customizations, the original  
/etc/profile should not be edited). BTW - on a non-Windows box, "hostname"  
must be in lower case, not upper case.

/etc/profile.local  
export NAME=/bin/hostname

After running "source /etc/profile.local" to activate the contents of the  
file I can successfully test the new variable, it does return the machine's  
hostname.

$NAME

But, when I modify the elasticsearch.yml file exactly as described

_node.name_ [http://node.name/](http://node.name/): ${NAME}

The result is that the elasticsearch service fails to start with the  
following error:

ELASTICSEAR-1 systemd[1]: Starting Starts and stops a single elasticsearch  
instance on this system...  
Dec 23 13:23:18 ELASTICSEAR-1 systemd[1]: PID file  
/var/run/elasticsearch/elasticsearch.pid not readable (yet?) after start.  
Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Started Starts and stops a single  
elasticsearch instance on this system.  
Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: elasticsearch.service: main  
process exited, code=exited, status=3/NOTIMPLEMENTED  
Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Unit elasticsearch.service  
entered failed state.  
I also tried without the curly braces, but then the string is read  
literally and not as a variable.  
Commenting out the attempt to set the node name to the hostname allows the  
elasticsearch service to start again.

From the above error(not implemented), is it possible that the current  
stable elasticsearch release does not support your recommendation and I  
need to maybe install an unstable version?

Thx,  
Tony

On Sunday, December 22, 2013 4:53:48 PM UTC-8, Karol Gwaj wrote:

> Take a look at default elasticsearch.yml:  
> [https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
> especially this part:
> 
> # Any element in the configuration can be replaced with environment variables
> 
> # by placing them in ${...} notation. For example:
> 
> # 
> 
> # node.rack: ${RACK\_ENV\_VAR}
> 
> so for example to accomplish this using environment variables:
> 
> - edit elasticsearch.yml:  
> node.name: ${NAME}
> 
> - create custom bash script:  
> #!/bin/bash
> 
> instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script
> 
> On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:
> 
> > Thx jorg, unfortunately your suggestions only configure actual strings,  
> > like my original example I'm hoping to automatically retrieve and insert  
> > the hostname of the machine. BTW if your suggestion is used in a config  
> > I've determined the "./bin/elasticsearch" should be omitted.
> > 
> > Karol,  
> > That looks closer to what I'm looking for but I'm uncertain if the  
> > variable can be setup at the beginning of the config file or can somehow be  
> > run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> > a variable when defining java variables, eg in a profile? I'm also  
> > surprised by your use of angle brackets, should they be used as you  
> > describe or do they only represent a general grouping of the statement?
> > 
> > Thx,  
> > Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/06c021c7-4ce4-411c-aa7d-82b35a86ab5f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06c021c7-4ce4-411c-aa7d-82b35a86ab5f%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 23, 2013, 10:19pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/8 "2013-12-23T22:19:46Z")

</div>

Additional minor update:  
I noticed that a number of similar "-Des" commands are implemented in the  
system Unit file referencing variables.  
So, I appended the -Des command which should set the node name to the  
hostname to the existing ExecStart string.

Simply stopping and restarting the elasticsearch service resulted in no  
name.  
So, rebooted the entire machine and checked status of the elasticsearch  
service.  
The elasticsearch service started and is running without error but  
When I pointed elasticsearch-head to the node, a random name was generated.

So, it looks more and more like the elasticsearch code I'm running doesn't  
support assigning the hostname to the node name.

Tony

On Saturday, December 21, 2013 3:51:33 PM UTC-8, Tony Su wrote:

> System:  
> Java openJDK 1.7  
> elasticsearch 0.90.7
> 
> Following some old instructions, I modified  
> /etc/sysconfig/elasticsearch  
> ES\_JAVA\_OPTS="-Des.node.name=$(name -n cut -d'.' -f1)"
> 
> But, that crashes the elasticsearch service on start.  
> I've tried the entry both with and without the double-quotes.
> 
> Commenting out the entry restores the elasticsearch functionality so it  
> starts up without error again.
> 
> At the moment, it looks like Elasticsearch might be using only a randomly  
> generated string to identify Elasticsearch nodes in a cluster.  
> Elasticsearch-head appears to be assigning random "friendly names" to each  
> node, but for consistency from session it would be far preferable for the  
> Elasticsearch Node Name to be the same as the Hostname of the machine.
> 
> Am hoping this is not a problem with openJDK and would have to install  
> Oracle Java instead (would be somewhat surprising if this would be a cause).
> 
> Thx,  
> TS

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f4416edb-98f5-47d2-8fad-660c963a61f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f4416edb-98f5-47d2-8fad-660c963a61f9%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 23, 2013, 10:25pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/9 "2013-12-23T22:25:38Z")

</div>

After posting my last, I noticed that auto-correct modified "systemd" to  
"system"

Should read  
I noticed that a number of similar "-Des" commands are implemented in the  
systemd Unit file referencing variables.

Tony

On Monday, December 23, 2013 2:19:46 PM UTC-8, Tony Su wrote:

> Additional minor update:  
> I noticed that a number of similar "-Des" commands are implemented in the  
> system Unit file referencing variables.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/04ada407-cb94-499a-89d7-cd20fada32a6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/04ada407-cb94-499a-89d7-cd20fada32a6%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 23, 2013, 10:54pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/10 "2013-12-23T22:54:35Z")

</div>

Note, if you are using systemd, you must set environment vars with  
systemctl [http://www.freedesktop.org/software/systemd/man/systemctl.html](http://www.freedesktop.org/software/systemd/man/systemctl.html)

Not sure what "-Des" commands are. If you mean the elasticsearch command  
line, many ES config variables can be prefixed with "es.", the "-D" flag is  
Java.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFezypW80PVubmCMp7WnrCaLqqHgdo9F-XxP0aEUPW0Qw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFezypW80PVubmCMp7WnrCaLqqHgdo9F-XxP0aEUPW0Qw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [December 24, 2013, 2:16am UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/11 "2013-12-24T02:16:45Z")

</div>

Im using elasticsearch version 0.90.7 (which is this same as the one you  
mentioned in your question)  
Also im running my elasticsearch cluster on ubuntu, so my example was more  
suited for this linux distribution

and coming back to your problem, to diagnose it you can:

- add _echo $NAME_ statement at the beginning of bin/elasticsearch script  
(if nothing is printed then your environment variable is not declared  
correctly)
- add _export NAME=`hostname`_ at the beginning of bin/elasticsearch script
- add _export NAME=$HOSTNAME_ at the beginning of bin/elasticsearch script

can you try the steps above first (one at the time), before defining your  
environment variable in /etc/profile.local

Cheers,

On Monday, December 23, 2013 9:52:40 PM UTC, Tony Su wrote:

> After considering this post,  
> I successfully created an environmental variable by adding to the bash  
> profile file (actually on the openSUSE I'm running, I created a file  
> /etc/profile.local which contains system customizations, the original  
> /etc/profile should not be edited). BTW - on a non-Windows box, "hostname"  
> must be in lower case, not upper case.
> 
> /etc/profile.local  
> export NAME=/bin/hostname
> 
> After running "source /etc/profile.local" to activate the contents of the  
> file I can successfully test the new variable, it does return the machine's  
> hostname.
> 
> $NAME
> 
> But, when I modify the elasticsearch.yml file exactly as described
> 
> _node.name_ [http://node.name/](http://node.name/): ${NAME}
> 
> The result is that the elasticsearch service fails to start with the  
> following error:
> 
> ELASTICSEAR-1 systemd[1]: Starting Starts and stops a single elasticsearch  
> instance on this system...  
> Dec 23 13:23:18 ELASTICSEAR-1 systemd[1]: PID file  
> /var/run/elasticsearch/elasticsearch.pid not readable (yet?) after start.  
> Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Started Starts and stops a  
> single elasticsearch instance on this system.  
> Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: elasticsearch.service: main  
> process exited, code=exited, status=3/NOTIMPLEMENTED  
> Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Unit elasticsearch.service  
> entered failed state.  
> I also tried without the curly braces, but then the string is read  
> literally and not as a variable.  
> Commenting out the attempt to set the node name to the hostname allows the  
> elasticsearch service to start again.
> 
> From the above error(not implemented), is it possible that the current  
> stable elasticsearch release does not support your recommendation and I  
> need to maybe install an unstable version?
> 
> Thx,  
> Tony
> 
> On Sunday, December 22, 2013 4:53:48 PM UTC-8, Karol Gwaj wrote:
> 
> > Take a look at default elasticsearch.yml:  
> > [https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
> > especially this part:
> > 
> > # Any element in the configuration can be replaced with environment variables
> > 
> > # by placing them in ${...} notation. For example:
> > 
> > # 
> > 
> > # node.rack: ${RACK\_ENV\_VAR}
> > 
> > so for example to accomplish this using environment variables:
> > 
> > - edit elasticsearch.yml:  
> > node.name: ${NAME}
> > 
> > - create custom bash script:  
> > #!/bin/bash
> > 
> > instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script
> > 
> > On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:
> > 
> > > Thx jorg, unfortunately your suggestions only configure actual strings,  
> > > like my original example I'm hoping to automatically retrieve and insert  
> > > the hostname of the machine. BTW if your suggestion is used in a config  
> > > I've determined the "./bin/elasticsearch" should be omitted.
> > > 
> > > Karol,  
> > > That looks closer to what I'm looking for but I'm uncertain if the  
> > > variable can be setup at the beginning of the config file or can somehow be  
> > > run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> > > a variable when defining java variables, eg in a profile? I'm also  
> > > surprised by your use of angle brackets, should they be used as you  
> > > describe or do they only represent a general grouping of the statement?
> > > 
> > > Thx,  
> > > Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e9d98262-4590-4923-bb26-d04622764d9b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e9d98262-4590-4923-bb26-d04622764d9b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 24, 2013, 3:22pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/12 "2013-12-24T15:22:50Z")

</div>

Hello Jorg,  
I was not aware of this page, but after skimming the page it is not what I  
need in this situation.  
The majority of the commands on this page are invoked as attributes of  
"systemctl" which is the command line tool to inspect, modify and manage  
systemd in a running system.  
I'm not sure why yet some commands are included that AFAIK are more  
appropriately invoked within a Unit config file, but maybe those commands  
can be invoked in both situations.

But, since these systemd environment commands are to be run from within  
systemctl, they're basically ways to modify a running environment  
interactively, they're not the way to setup and modify the environment on  
bootup.

In systemd, environment variables can be setup during boot, primarily in  
the ".target" Unit files, but because systemd is uniquely fully compatible  
with other Linux subsystems, almost all the "traditional" ways to setup,  
modify and run is supported. In openSUSE' case, it's migrating from the  
well known SystemVinit subsystem, so until legacy init and bash ways of  
invoking code are replaced, they are a perfectly legitimate way of doing  
things, still.

So, that is why in my previous post I described how I "traditionally" used  
the bash script way of creating an environment variable  
(/etc/profile.local) and then tested to make sure it works... So that  
doesn't appear to be more problem.

Instead, I believe the problem sounds explicitly Elasticsearch code when  
the following very specific error was returned  
elasticsearch.service: main process exited, code=exited,  
status=3/NOTIMPLEMENTED

Could have been any error, but one so specific?

Tony

On Monday, December 23, 2013 2:54:35 PM UTC-8, Jörg Prante wrote:

> Note, if you are using systemd, you must set environment vars with  
> systemctl [systemctl](http://www.freedesktop.org/software/systemd/man/systemctl.html)
> 
> Not sure what "-Des" commands are. If you mean the elasticsearch command  
> line, many ES config variables can be prefixed with "es.", the "-D" flag is  
> Java.
> 
> Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2c3eab8b-8446-4d57-b3f2-c0d10eef79bb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2c3eab8b-8446-4d57-b3f2-c0d10eef79bb%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 24, 2013, 4:24pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/13 "2013-12-24T16:24:02Z")

</div>

OK,  
I ran each of your tests, but because I'm invoking elasticsearch as a  
service and not from the CLI, I interactively ran the command you wanted  
prepended, then started the elasticsearch service, then reloaded  
elasticsearch-head pointing to the elasticsearch node.

So, as follows, I first disabled the service so it doesn't start  
automatically. After each block below I ran elasticsearch-head with the  
same results, a random "friendly" node name was created in  
elasticsearch-head

# echo $NAME

/bin/hostname

# $NAME

ELASTICSEAR-1

# systemctl stop elasticsearch.service

# export NAME=hostname

# systemctl start elasticsearch.service

# systemtcl stop elasticsearch.service

# export NAME=$HOSTNAME

# systemctl start elasticsearch.service

# systemctl stop elasticsearch.service

# export NAME=$hostname

# systemctl start elasticsearch.service

For your reference is the contents of the elasticsearch.service Unit file  
(aka service configuration file). Although it references many exterior  
files (the -Des commands), I doubt in this case anything in them are likely  
to be relevant because we seem to be dealing with a variable (if supported)  
is a null value.

[Unit]  
Description=Starts and stops a single elasticsearch instance on this system  
Documentation=[http://www.elasticsearch.org](http://www.elasticsearch.org)  
[Service]  
Type=forking  
EnvironmentFile=/etc/sysconfig/elasticsearch  
User=elasticsearch  
Group=elasticsearch  
PIDFile=/var/run/elasticsearch/elasticsearch.pid  
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p  
/var/run/elasticsearch/elasticsearch.pid -Des.default.config=$CONF\_FILE  
-Des.default.path.home=$ES\_HOME -Des.default.path.logs=$LOG\_DIR  
-Des.default.path.data=$DATA\_DIR -Des.default.path.work=$WORK\_DIR  
-Des.default.path.conf=$CONF\_DIR

# See MAX\_OPEN\_FILES

LimitNOFILE=65535

# See MAX\_LOCKED\_MEMORY, use "infinity" when MAX\_LOCKED\_MEMORY=unlimited

and using bootstrap.mlockall: true  
#LimitMEMLOCK=infinity  
[Install]  
WantedBy=multi-user.target

A thought, if you're running the same version as me, I wonder if there  
might be a difference between the RPM build (which I am using) and yours  
which of course is a DEB build unless you built from source. I'm using the  
RPM downloaded directly through the Elasticsearch website.

Tony

On Monday, December 23, 2013 6:16:45 PM UTC-8, Karol Gwaj wrote:

> Im using elasticsearch version 0.90.7 (which is this same as the one you  
> mentioned in your question)  
> Also im running my elasticsearch cluster on ubuntu, so my example was more  
> suited for this linux distribution
> 
> and coming back to your problem, to diagnose it you can:
> 
> - add _echo $NAME_ statement at the beginning of bin/elasticsearch script  
> (if nothing is printed then your environment variable is not declared  
> correctly)
> - add _export NAME=`hostname`_ at the beginning of bin/elasticsearch  
> script
> - add _export NAME=$HOSTNAME_ at the beginning of bin/elasticsearch script
> 
> can you try the steps above first (one at the time), before defining your  
> environment variable in /etc/profile.local
> 
> Cheers,
> 
> On Monday, December 23, 2013 9:52:40 PM UTC, Tony Su wrote:
> 
> > After considering this post,  
> > I successfully created an environmental variable by adding to the bash  
> > profile file (actually on the openSUSE I'm running, I created a file  
> > /etc/profile.local which contains system customizations, the original  
> > /etc/profile should not be edited). BTW - on a non-Windows box, "hostname"  
> > must be in lower case, not upper case.
> > 
> > /etc/profile.local  
> > export NAME=/bin/hostname
> > 
> > After running "source /etc/profile.local" to activate the contents of the  
> > file I can successfully test the new variable, it does return the machine's  
> > hostname.
> > 
> > $NAME
> > 
> > But, when I modify the elasticsearch.yml file exactly as described
> > 
> > _node.name_ [http://node.name/](http://node.name/): ${NAME}
> > 
> > The result is that the elasticsearch service fails to start with the  
> > following error:
> > 
> > ELASTICSEAR-1 systemd[1]: Starting Starts and stops a single  
> > elasticsearch instance on this system...  
> > Dec 23 13:23:18 ELASTICSEAR-1 systemd[1]: PID file  
> > /var/run/elasticsearch/elasticsearch.pid not readable (yet?) after start.  
> > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Started Starts and stops a  
> > single elasticsearch instance on this system.  
> > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: elasticsearch.service: main  
> > process exited, code=exited, status=3/NOTIMPLEMENTED  
> > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Unit elasticsearch.service  
> > entered failed state.  
> > I also tried without the curly braces, but then the string is read  
> > literally and not as a variable.  
> > Commenting out the attempt to set the node name to the hostname allows  
> > the elasticsearch service to start again.
> > 
> > From the above error(not implemented), is it possible that the current  
> > stable elasticsearch release does not support your recommendation and I  
> > need to maybe install an unstable version?
> > 
> > Thx,  
> > Tony
> > 
> > On Sunday, December 22, 2013 4:53:48 PM UTC-8, Karol Gwaj wrote:
> > 
> > > Take a look at default elasticsearch.yml:  
> > > [https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
> > > especially this part:
> > > 
> > > # Any element in the configuration can be replaced with environment variables
> > > 
> > > # by placing them in ${...} notation. For example:
> > > 
> > > # 
> > > 
> > > # node.rack: ${RACK\_ENV\_VAR}
> > > 
> > > so for example to accomplish this using environment variables:
> > > 
> > > - edit elasticsearch.yml:  
> > > node.name: ${NAME}
> > > 
> > > - create custom bash script:  
> > > #!/bin/bash
> > > 
> > > instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script
> > > 
> > > On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:
> > > 
> > > > Thx jorg, unfortunately your suggestions only configure actual strings,  
> > > > like my original example I'm hoping to automatically retrieve and insert  
> > > > the hostname of the machine. BTW if your suggestion is used in a config  
> > > > I've determined the "./bin/elasticsearch" should be omitted.
> > > > 
> > > > Karol,  
> > > > That looks closer to what I'm looking for but I'm uncertain if the  
> > > > variable can be setup at the beginning of the config file or can somehow be  
> > > > run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> > > > a variable when defining java variables, eg in a profile? I'm also  
> > > > surprised by your use of angle brackets, should they be used as you  
> > > > describe or do they only represent a general grouping of the statement?
> > > > 
> > > > Thx,  
> > > > Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6aa7bf7b-0af9-48fa-adff-e5591102544b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6aa7bf7b-0af9-48fa-adff-e5591102544b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [December 24, 2013, 8:28pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/14 "2013-12-24T20:28:09Z")

</div>

yep, my setup is a little bit different from yours  
i actually downloaded elasticsearch as tar.gz file

probably the problem you are experiencing is related more to the fact that  
systemctl is not passing environment variables to executed script  
i had similar problem with upstart (which is equivalent of systemctl on  
ubuntu)

from what i know about systemctl, the way to define environment variables  
that will be passed to executed script is through EnvironmentFile  
so maybe try to define NAME environment variable in  
_/etc/sysconfig/elasticsearch_ (EnvironmentFile )

from your service unit file i see that elasticsearch startup script is  
located in: _/usr/share/elasticsearch/bin/elasticsearch_  
if you add definition of your environment variable at the beginning of this  
file then you will not have to worry about systemctl not passing  
environment variables to your script

so try something like that first:

export NAME=$HOSTNAME  
echo $NAME # this should  
print your hostname  
/usr/share/elasticsearch/bin/elasticsearch

On Tuesday, December 24, 2013 4:24:02 PM UTC, Tony Su wrote:

> OK,  
> I ran each of your tests, but because I'm invoking elasticsearch as a  
> service and not from the CLI, I interactively ran the command you wanted  
> prepended, then started the elasticsearch service, then reloaded  
> elasticsearch-head pointing to the elasticsearch node.
> 
> So, as follows, I first disabled the service so it doesn't start  
> automatically. After each block below I ran elasticsearch-head with the  
> same results, a random "friendly" node name was created in  
> elasticsearch-head
> 
> # echo $NAME
> 
> /bin/hostname
> 
> # $NAME
> 
> ELASTICSEAR-1
> 
> # systemctl stop elasticsearch.service
> 
> # export NAME=hostname
> 
> # systemctl start elasticsearch.service
> 
> # systemtcl stop elasticsearch.service
> 
> # export NAME=$HOSTNAME
> 
> # systemctl start elasticsearch.service
> 
> # systemctl stop elasticsearch.service
> 
> # export NAME=$hostname
> 
> # systemctl start elasticsearch.service
> 
> For your reference is the contents of the elasticsearch.service Unit file  
> (aka service configuration file). Although it references many exterior  
> files (the -Des commands), I doubt in this case anything in them are likely  
> to be relevant because we seem to be dealing with a variable (if supported)  
> is a null value.
> 
> [Unit]  
> Description=Starts and stops a single elasticsearch instance on this system  
> Documentation=[http://www.elasticsearch.org](http://www.elasticsearch.org)  
> [Service]  
> Type=forking  
> EnvironmentFile=/etc/sysconfig/elasticsearch  
> User=elasticsearch  
> Group=elasticsearch  
> PIDFile=/var/run/elasticsearch/elasticsearch.pid  
> ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p  
> /var/run/elasticsearch/elasticsearch.pid -Des.default.config=$CONF\_FILE  
> -Des.default.path.home=$ES\_HOME -Des.default.path.logs=$LOG\_DIR  
> -Des.default.path.data=$DATA\_DIR -Des.default.path.work=$WORK\_DIR  
> -Des.default.path.conf=$CONF\_DIR
> 
> # See MAX\_OPEN\_FILES
> 
> LimitNOFILE=65535
> 
> # See MAX\_LOCKED\_MEMORY, use "infinity" when MAX\_LOCKED\_MEMORY=unlimited
> 
> and using bootstrap.mlockall: true  
> #LimitMEMLOCK=infinity  
> [Install]  
> WantedBy=multi-user.target
> 
> A thought, if you're running the same version as me, I wonder if there  
> might be a difference between the RPM build (which I am using) and yours  
> which of course is a DEB build unless you built from source. I'm using the  
> RPM downloaded directly through the Elasticsearch website.
> 
> Tony
> 
> On Monday, December 23, 2013 6:16:45 PM UTC-8, Karol Gwaj wrote:
> 
> > Im using elasticsearch version 0.90.7 (which is this same as the one you  
> > mentioned in your question)  
> > Also im running my elasticsearch cluster on ubuntu, so my example was  
> > more suited for this linux distribution
> > 
> > and coming back to your problem, to diagnose it you can:
> > 
> > - add _echo $NAME_ statement at the beginning of bin/elasticsearch  
> > script (if nothing is printed then your environment variable is not  
> > declared correctly)
> > - add _export NAME=`hostname`_ at the beginning of bin/elasticsearch  
> > script
> > - add _export NAME=$HOSTNAME_ at the beginning of bin/elasticsearch  
> > script
> > 
> > can you try the steps above first (one at the time), before defining your  
> > environment variable in /etc/profile.local
> > 
> > Cheers,
> > 
> > On Monday, December 23, 2013 9:52:40 PM UTC, Tony Su wrote:
> > 
> > > After considering this post,  
> > > I successfully created an environmental variable by adding to the bash  
> > > profile file (actually on the openSUSE I'm running, I created a file  
> > > /etc/profile.local which contains system customizations, the original  
> > > /etc/profile should not be edited). BTW - on a non-Windows box, "hostname"  
> > > must be in lower case, not upper case.
> > > 
> > > /etc/profile.local  
> > > export NAME=/bin/hostname
> > > 
> > > After running "source /etc/profile.local" to activate the contents of  
> > > the file I can successfully test the new variable, it does return the  
> > > machine's hostname.
> > > 
> > > $NAME
> > > 
> > > But, when I modify the elasticsearch.yml file exactly as described
> > > 
> > > _node.name_ [http://node.name/](http://node.name/): ${NAME}
> > > 
> > > The result is that the elasticsearch service fails to start with the  
> > > following error:
> > > 
> > > ELASTICSEAR-1 systemd[1]: Starting Starts and stops a single  
> > > elasticsearch instance on this system...  
> > > Dec 23 13:23:18 ELASTICSEAR-1 systemd[1]: PID file  
> > > /var/run/elasticsearch/elasticsearch.pid not readable (yet?) after start.  
> > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Started Starts and stops a  
> > > single elasticsearch instance on this system.  
> > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: elasticsearch.service: main  
> > > process exited, code=exited, status=3/NOTIMPLEMENTED  
> > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Unit elasticsearch.service  
> > > entered failed state.  
> > > I also tried without the curly braces, but then the string is read  
> > > literally and not as a variable.  
> > > Commenting out the attempt to set the node name to the hostname allows  
> > > the elasticsearch service to start again.
> > > 
> > > From the above error(not implemented), is it possible that the current  
> > > stable elasticsearch release does not support your recommendation and I  
> > > need to maybe install an unstable version?
> > > 
> > > Thx,  
> > > Tony
> > > 
> > > On Sunday, December 22, 2013 4:53:48 PM UTC-8, Karol Gwaj wrote:
> > > 
> > > > Take a look at default elasticsearch.yml:  
> > > > [https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
> > > > especially this part:
> > > > 
> > > > # Any element in the configuration can be replaced with environment variables
> > > > 
> > > > # by placing them in ${...} notation. For example:
> > > > 
> > > > # 
> > > > 
> > > > # node.rack: ${RACK\_ENV\_VAR}
> > > > 
> > > > so for example to accomplish this using environment variables:
> > > > 
> > > > - edit elasticsearch.yml:  
> > > > node.name: ${NAME}
> > > > 
> > > > - create custom bash script:  
> > > > #!/bin/bash
> > > > 
> > > > instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script
> > > > 
> > > > On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:
> > > > 
> > > > > Thx jorg, unfortunately your suggestions only configure actual  
> > > > > strings, like my original example I'm hoping to automatically retrieve and  
> > > > > insert the hostname of the machine. BTW if your suggestion is used in a  
> > > > > config I've determined the "./bin/elasticsearch" should be omitted.
> > > > > 
> > > > > Karol,  
> > > > > That looks closer to what I'm looking for but I'm uncertain if the  
> > > > > variable can be setup at the beginning of the config file or can somehow be  
> > > > > run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> > > > > a variable when defining java variables, eg in a profile? I'm also  
> > > > > surprised by your use of angle brackets, should they be used as you  
> > > > > describe or do they only represent a general grouping of the statement?
> > > > > 
> > > > > Thx,  
> > > > > Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/de1daa7a-810a-4aa9-95dc-80bc4e751261%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/de1daa7a-810a-4aa9-95dc-80bc4e751261%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [December 30, 2013, 5:38pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/15 "2013-12-30T17:38:46Z")

</div>

Minor update:  
I tried the suggestion to prepend setting the environmental variables to  
map $hostname to a variable at the beginning of an elasticsearch config  
file and it doesn't work. No error, it just doesn't result in expected  
functionality.

So,  
Am going to add CentOS and Ubuntu machine to my cluster and see if there is  
any diff. since CentOS still uses SystemVinit and Ubuntu uses Upstart for  
subsystems management.

In the meantime, for the life of me, if the Elasticsearch coding is  
correct, I can't imagine how a Java app shouldn't be able to read  
systemwide variables into its own configuration, particularly if the build  
(eg rpm or deb) obviously targets a Linux system. So, although I can also  
briefly mention that openSUSE (like some other distros like Mandriva) uses  
an update-alternatives utility to manage configuration and management of  
the Java environment(including easily switching between different Java  
installed on the same system), I still would assume that if Elasticsearch  
is coded properly that shouldn't make a diff because I doubt that node  
names are variables that would be scoped to only Java use.

If anyone can point to the general part of the elasticsearch code that is  
supposed to interpret, use and/or dynamically generate the strings that are  
used for node identification, I'd be willing to take a brief look to see if  
there might be anything obvious that might be implemented differently.

In the meantime, will be testing the other machines I mentioned I'm adding.  
If I see the same behavior using the pre-built packages, then I'll likely  
try building from source if that's how you're successfully getting this to  
work (or are the tar you're using simply jar files?).

Tony

On Tuesday, December 24, 2013 12:28:09 PM UTC-8, Karol Gwaj wrote:

> yep, my setup is a little bit different from yours  
> i actually downloaded elasticsearch as tar.gz file
> 
> probably the problem you are experiencing is related more to the fact that  
> systemctl is not passing environment variables to executed script  
> i had similar problem with upstart (which is equivalent of systemctl on  
> ubuntu)
> 
> from what i know about systemctl, the way to define environment variables  
> that will be passed to executed script is through EnvironmentFile  
> so maybe try to define NAME environment variable in  
> _/etc/sysconfig/elasticsearch_ (EnvironmentFile )
> 
> from your service unit file i see that elasticsearch startup script is  
> located in: _/usr/share/elasticsearch/bin/elasticsearch_  
> if you add definition of your environment variable at the beginning of  
> this file then you will not have to worry about systemctl not passing  
> environment variables to your script
> 
> so try something like that first:
> 
> export NAME=$HOSTNAME  
> echo $NAME # this should  
> print your hostname  
> /usr/share/elasticsearch/bin/elasticsearch
> 
> On Tuesday, December 24, 2013 4:24:02 PM UTC, Tony Su wrote:
> 
> > OK,  
> > I ran each of your tests, but because I'm invoking elasticsearch as a  
> > service and not from the CLI, I interactively ran the command you wanted  
> > prepended, then started the elasticsearch service, then reloaded  
> > elasticsearch-head pointing to the elasticsearch node.
> > 
> > So, as follows, I first disabled the service so it doesn't start  
> > automatically. After each block below I ran elasticsearch-head with the  
> > same results, a random "friendly" node name was created in  
> > elasticsearch-head
> > 
> > # echo $NAME
> > 
> > /bin/hostname
> > 
> > # $NAME
> > 
> > ELASTICSEAR-1
> > 
> > # systemctl stop elasticsearch.service
> > 
> > # export NAME=hostname
> > 
> > # systemctl start elasticsearch.service
> > 
> > # systemtcl stop elasticsearch.service
> > 
> > # export NAME=$HOSTNAME
> > 
> > # systemctl start elasticsearch.service
> > 
> > # systemctl stop elasticsearch.service
> > 
> > # export NAME=$hostname
> > 
> > # systemctl start elasticsearch.service
> > 
> > For your reference is the contents of the elasticsearch.service Unit file  
> > (aka service configuration file). Although it references many exterior  
> > files (the -Des commands), I doubt in this case anything in them are likely  
> > to be relevant because we seem to be dealing with a variable (if supported)  
> > is a null value.
> > 
> > [Unit]  
> > Description=Starts and stops a single elasticsearch instance on this  
> > system  
> > Documentation=[http://www.elasticsearch.org](http://www.elasticsearch.org)  
> > [Service]  
> > Type=forking  
> > EnvironmentFile=/etc/sysconfig/elasticsearch  
> > User=elasticsearch  
> > Group=elasticsearch  
> > PIDFile=/var/run/elasticsearch/elasticsearch.pid  
> > ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p  
> > /var/run/elasticsearch/elasticsearch.pid -Des.default.config=$CONF\_FILE  
> > -Des.default.path.home=$ES\_HOME -Des.default.path.logs=$LOG\_DIR  
> > -Des.default.path.data=$DATA\_DIR -Des.default.path.work=$WORK\_DIR  
> > -Des.default.path.conf=$CONF\_DIR
> > 
> > # See MAX\_OPEN\_FILES
> > 
> > LimitNOFILE=65535
> > 
> > # See MAX\_LOCKED\_MEMORY, use "infinity" when MAX\_LOCKED\_MEMORY=unlimited
> > 
> > and using bootstrap.mlockall: true  
> > #LimitMEMLOCK=infinity  
> > [Install]  
> > WantedBy=multi-user.target
> > 
> > A thought, if you're running the same version as me, I wonder if there  
> > might be a difference between the RPM build (which I am using) and yours  
> > which of course is a DEB build unless you built from source. I'm using the  
> > RPM downloaded directly through the Elasticsearch website.
> > 
> > Tony
> > 
> > On Monday, December 23, 2013 6:16:45 PM UTC-8, Karol Gwaj wrote:
> > 
> > > Im using elasticsearch version 0.90.7 (which is this same as the one you  
> > > mentioned in your question)  
> > > Also im running my elasticsearch cluster on ubuntu, so my example was  
> > > more suited for this linux distribution
> > > 
> > > and coming back to your problem, to diagnose it you can:
> > > 
> > > - add _echo $NAME_ statement at the beginning of bin/elasticsearch  
> > > script (if nothing is printed then your environment variable is not  
> > > declared correctly)
> > > - add _export NAME=`hostname`_ at the beginning of bin/elasticsearch  
> > > script
> > > - add _export NAME=$HOSTNAME_ at the beginning of bin/elasticsearch  
> > > script
> > > 
> > > can you try the steps above first (one at the time), before defining  
> > > your environment variable in /etc/profile.local
> > > 
> > > Cheers,
> > > 
> > > On Monday, December 23, 2013 9:52:40 PM UTC, Tony Su wrote:
> > > 
> > > > After considering this post,  
> > > > I successfully created an environmental variable by adding to the bash  
> > > > profile file (actually on the openSUSE I'm running, I created a file  
> > > > /etc/profile.local which contains system customizations, the original  
> > > > /etc/profile should not be edited). BTW - on a non-Windows box, "hostname"  
> > > > must be in lower case, not upper case.
> > > > 
> > > > /etc/profile.local  
> > > > export NAME=/bin/hostname
> > > > 
> > > > After running "source /etc/profile.local" to activate the contents of  
> > > > the file I can successfully test the new variable, it does return the  
> > > > machine's hostname.
> > > > 
> > > > $NAME
> > > > 
> > > > But, when I modify the elasticsearch.yml file exactly as described
> > > > 
> > > > _node.name_ [http://node.name/](http://node.name/): ${NAME}
> > > > 
> > > > The result is that the elasticsearch service fails to start with the  
> > > > following error:
> > > > 
> > > > ELASTICSEAR-1 systemd[1]: Starting Starts and stops a single  
> > > > elasticsearch instance on this system...  
> > > > Dec 23 13:23:18 ELASTICSEAR-1 systemd[1]: PID file  
> > > > /var/run/elasticsearch/elasticsearch.pid not readable (yet?) after start.  
> > > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Started Starts and stops a  
> > > > single elasticsearch instance on this system.  
> > > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: elasticsearch.service: main  
> > > > process exited, code=exited, status=3/NOTIMPLEMENTED  
> > > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Unit elasticsearch.service  
> > > > entered failed state.  
> > > > I also tried without the curly braces, but then the string is read  
> > > > literally and not as a variable.  
> > > > Commenting out the attempt to set the node name to the hostname allows  
> > > > the elasticsearch service to start again.
> > > > 
> > > > From the above error(not implemented), is it possible that the current  
> > > > stable elasticsearch release does not support your recommendation and I  
> > > > need to maybe install an unstable version?
> > > > 
> > > > Thx,  
> > > > Tony
> > > > 
> > > > On Sunday, December 22, 2013 4:53:48 PM UTC-8, Karol Gwaj wrote:
> > > > 
> > > > > Take a look at default elasticsearch.yml:  
> > > > > [https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
> > > > > especially this part:
> > > > > 
> > > > > # Any element in the configuration can be replaced with environment variables
> > > > > 
> > > > > # by placing them in ${...} notation. For example:
> > > > > 
> > > > > # 
> > > > > 
> > > > > # node.rack: ${RACK\_ENV\_VAR}
> > > > > 
> > > > > so for example to accomplish this using environment variables:
> > > > > 
> > > > > - edit elasticsearch.yml:  
> > > > > node.name: ${NAME}
> > > > > 
> > > > > - create custom bash script:  
> > > > > #!/bin/bash
> > > > > 
> > > > > instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script
> > > > > 
> > > > > On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:
> > > > > 
> > > > > > Thx jorg, unfortunately your suggestions only configure actual  
> > > > > > strings, like my original example I'm hoping to automatically retrieve and  
> > > > > > insert the hostname of the machine. BTW if your suggestion is used in a  
> > > > > > config I've determined the "./bin/elasticsearch" should be omitted.
> > > > > > 
> > > > > > Karol,  
> > > > > > That looks closer to what I'm looking for but I'm uncertain if the  
> > > > > > variable can be setup at the beginning of the config file or can somehow be  
> > > > > > run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> > > > > > a variable when defining java variables, eg in a profile? I'm also  
> > > > > > surprised by your use of angle brackets, should they be used as you  
> > > > > > describe or do they only represent a general grouping of the statement?
> > > > > > 
> > > > > > Thx,  
> > > > > > Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/898e884b-cd8d-46f7-ae0a-ad6420acab91%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/898e884b-cd8d-46f7-ae0a-ad6420acab91%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 30, 2013, 9:31pm UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/16 "2013-12-30T21:31:11Z")

</div>

You can just download the tar.gz, unpack it, and start ES with  
./bin/elasticsearch -Des.node.name=... or set ES\_JAVA\_OPTS to "-  
Des.node.name=...", in any startup script you prefer.

There is no need to build from source. ES behaves just like any Java app I  
know of that uses Java system properties, for example, JBoss or Tomcat.

Since interpreting Java system properties have no relationship with System  
V or systemd, I'm not sure how I can follow you.

FWIW I use ES on RHEL with the service wrapper  
[https://github.com/elasticsearch/elasticsearch-servicewrapper](https://github.com/elasticsearch/elasticsearch-servicewrapper) by just  
adding a symlink in the /etc/init.d folder.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH\_QE8\_GYBjTbGSZUXrr56Cqb7%3DVhz%3DySYudOQyTgyG9g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH_QE8_GYBjTbGSZUXrr56Cqb7%3DVhz%3DySYudOQyTgyG9g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [December 31, 2013, 1:25am UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/17 "2013-12-31T01:25:12Z")

</div>

it is very weird that it is not working for you, im using this same setup  
in my cluster (hostname as node name), and it worked fine from first attempt  
my guess will be that there is some small issue that i took as granted and  
didnt explained it clearly  
so lets do it step by step:

- open file: _/usr/share/elasticsearch/bin/elasticsearch ,_ it should start  
with something like that:

#!/bin/sh

# OPTIONS:

# - f: start in the foreground

- modify it to look like this:

#!/bin/sh

export NAME=`hostname`

# OPTIONS:

# - f: start in the foreground

- take note that `hostname` is in backquotes and it is equivalent to  
$(hostname), so use whichever notation you prefer

- overall it is not advised to mess with \*/usr/share/elasticsearch/bin/elasticsearch  
\*file (as you may need to replace it later with new version)  
better to put your changes into include file (and reference it using  
ES\_INCLUDE) or call elasticsearch script from your custom script  
but try the steps above before making it pretty

BTW, the code in elasticsearch responsible for replacing ${...}  
placeholders is located  
in: org.elasticsearch.common.settings.ImmutableSettings.replacePropertyPlaceholders

Cheers,

On Monday, December 30, 2013 5:38:46 PM UTC, Tony Su wrote:

> Minor update:  
> I tried the suggestion to prepend setting the environmental variables to  
> map $hostname to a variable at the beginning of an elasticsearch config  
> file and it doesn't work. No error, it just doesn't result in expected  
> functionality.
> 
> So,  
> Am going to add CentOS and Ubuntu machine to my cluster and see if there  
> is any diff. since CentOS still uses SystemVinit and Ubuntu uses  
> Upstart for subsystems management.
> 
> In the meantime, for the life of me, if the Elasticsearch coding is  
> correct, I can't imagine how a Java app shouldn't be able to read  
> systemwide variables into its own configuration, particularly if the build  
> (eg rpm or deb) obviously targets a Linux system. So, although I can also  
> briefly mention that openSUSE (like some other distros like Mandriva) uses  
> an update-alternatives utility to manage configuration and management of  
> the Java environment(including easily switching between different Java  
> installed on the same system), I still would assume that if Elasticsearch  
> is coded properly that shouldn't make a diff because I doubt that node  
> names are variables that would be scoped to only Java use.
> 
> If anyone can point to the general part of the elasticsearch code that is  
> supposed to interpret, use and/or dynamically generate the strings that are  
> used for node identification, I'd be willing to take a brief look to see if  
> there might be anything obvious that might be implemented differently.
> 
> In the meantime, will be testing the other machines I mentioned I'm  
> adding. If I see the same behavior using the pre-built packages, then I'll  
> likely try building from source if that's how you're successfully getting  
> this to work (or are the tar you're using simply jar files?).
> 
> Tony
> 
> On Tuesday, December 24, 2013 12:28:09 PM UTC-8, Karol Gwaj wrote:
> 
> > yep, my setup is a little bit different from yours  
> > i actually downloaded elasticsearch as tar.gz file
> > 
> > probably the problem you are experiencing is related more to the fact  
> > that systemctl is not passing environment variables to executed script  
> > i had similar problem with upstart (which is equivalent of systemctl on  
> > ubuntu)
> > 
> > from what i know about systemctl, the way to define environment variables  
> > that will be passed to executed script is through EnvironmentFile  
> > so maybe try to define NAME environment variable in  
> > _/etc/sysconfig/elasticsearch_ (EnvironmentFile )
> > 
> > from your service unit file i see that elasticsearch startup script is  
> > located in: _/usr/share/elasticsearch/bin/elasticsearch_  
> > if you add definition of your environment variable at the beginning of  
> > this file then you will not have to worry about systemctl not passing  
> > environment variables to your script
> > 
> > so try something like that first:
> > 
> > export NAME=$HOSTNAME  
> > echo $NAME # this should  
> > print your hostname  
> > /usr/share/elasticsearch/bin/elasticsearch
> > 
> > On Tuesday, December 24, 2013 4:24:02 PM UTC, Tony Su wrote:
> > 
> > > OK,  
> > > I ran each of your tests, but because I'm invoking elasticsearch as a  
> > > service and not from the CLI, I interactively ran the command you wanted  
> > > prepended, then started the elasticsearch service, then reloaded  
> > > elasticsearch-head pointing to the elasticsearch node.
> > > 
> > > So, as follows, I first disabled the service so it doesn't start  
> > > automatically. After each block below I ran elasticsearch-head with the  
> > > same results, a random "friendly" node name was created in  
> > > elasticsearch-head
> > > 
> > > # echo $NAME
> > > 
> > > /bin/hostname
> > > 
> > > # $NAME
> > > 
> > > ELASTICSEAR-1
> > > 
> > > # systemctl stop elasticsearch.service
> > > 
> > > # export NAME=hostname
> > > 
> > > # systemctl start elasticsearch.service
> > > 
> > > # systemtcl stop elasticsearch.service
> > > 
> > > # export NAME=$HOSTNAME
> > > 
> > > # systemctl start elasticsearch.service
> > > 
> > > # systemctl stop elasticsearch.service
> > > 
> > > # export NAME=$hostname
> > > 
> > > # systemctl start elasticsearch.service
> > > 
> > > For your reference is the contents of the elasticsearch.service Unit  
> > > file (aka service configuration file). Although it references many exterior  
> > > files (the -Des commands), I doubt in this case anything in them are likely  
> > > to be relevant because we seem to be dealing with a variable (if supported)  
> > > is a null value.
> > > 
> > > [Unit]  
> > > Description=Starts and stops a single elasticsearch instance on this  
> > > system  
> > > Documentation=[http://www.elasticsearch.org](http://www.elasticsearch.org)  
> > > [Service]  
> > > Type=forking  
> > > EnvironmentFile=/etc/sysconfig/elasticsearch  
> > > User=elasticsearch  
> > > Group=elasticsearch  
> > > PIDFile=/var/run/elasticsearch/elasticsearch.pid  
> > > ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p  
> > > /var/run/elasticsearch/elasticsearch.pid -Des.default.config=$CONF\_FILE  
> > > -Des.default.path.home=$ES\_HOME -Des.default.path.logs=$LOG\_DIR  
> > > -Des.default.path.data=$DATA\_DIR -Des.default.path.work=$WORK\_DIR  
> > > -Des.default.path.conf=$CONF\_DIR
> > > 
> > > # See MAX\_OPEN\_FILES
> > > 
> > > LimitNOFILE=65535
> > > 
> > > # See MAX\_LOCKED\_MEMORY, use "infinity" when MAX\_LOCKED\_MEMORY=unlimited
> > > 
> > > and using bootstrap.mlockall: true  
> > > #LimitMEMLOCK=infinity  
> > > [Install]  
> > > WantedBy=multi-user.target
> > > 
> > > A thought, if you're running the same version as me, I wonder if there  
> > > might be a difference between the RPM build (which I am using) and yours  
> > > which of course is a DEB build unless you built from source. I'm using the  
> > > RPM downloaded directly through the Elasticsearch website.
> > > 
> > > Tony
> > > 
> > > On Monday, December 23, 2013 6:16:45 PM UTC-8, Karol Gwaj wrote:
> > > 
> > > > Im using elasticsearch version 0.90.7 (which is this same as the one  
> > > > you mentioned in your question)  
> > > > Also im running my elasticsearch cluster on ubuntu, so my example was  
> > > > more suited for this linux distribution
> > > > 
> > > > and coming back to your problem, to diagnose it you can:
> > > > 
> > > > - add _echo $NAME_ statement at the beginning of bin/elasticsearch  
> > > > script (if nothing is printed then your environment variable is not  
> > > > declared correctly)
> > > > - add _export NAME=`hostname`_ at the beginning of bin/elasticsearch  
> > > > script
> > > > - add _export NAME=$HOSTNAME_ at the beginning of bin/elasticsearch  
> > > > script
> > > > 
> > > > can you try the steps above first (one at the time), before defining  
> > > > your environment variable in /etc/profile.local
> > > > 
> > > > Cheers,
> > > > 
> > > > On Monday, December 23, 2013 9:52:40 PM UTC, Tony Su wrote:
> > > > 
> > > > > After considering this post,  
> > > > > I successfully created an environmental variable by adding to the bash  
> > > > > profile file (actually on the openSUSE I'm running, I created a file  
> > > > > /etc/profile.local which contains system customizations, the original  
> > > > > /etc/profile should not be edited). BTW - on a non-Windows box, "hostname"  
> > > > > must be in lower case, not upper case.
> > > > > 
> > > > > /etc/profile.local  
> > > > > export NAME=/bin/hostname
> > > > > 
> > > > > After running "source /etc/profile.local" to activate the contents of  
> > > > > the file I can successfully test the new variable, it does return the  
> > > > > machine's hostname.
> > > > > 
> > > > > $NAME
> > > > > 
> > > > > But, when I modify the elasticsearch.yml file exactly as described
> > > > > 
> > > > > _node.name_ [http://node.name/](http://node.name/): ${NAME}
> > > > > 
> > > > > The result is that the elasticsearch service fails to start with the  
> > > > > following error:
> > > > > 
> > > > > ELASTICSEAR-1 systemd[1]: Starting Starts and stops a single  
> > > > > elasticsearch instance on this system...  
> > > > > Dec 23 13:23:18 ELASTICSEAR-1 systemd[1]: PID file  
> > > > > /var/run/elasticsearch/elasticsearch.pid not readable (yet?) after start.  
> > > > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Started Starts and stops a  
> > > > > single elasticsearch instance on this system.  
> > > > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: elasticsearch.service: main  
> > > > > process exited, code=exited, status=3/NOTIMPLEMENTED  
> > > > > Dec 23 13:23:43 ELASTICSEAR-1 systemd[1]: Unit elasticsearch.service  
> > > > > entered failed state.  
> > > > > I also tried without the curly braces, but then the string is read  
> > > > > literally and not as a variable.  
> > > > > Commenting out the attempt to set the node name to the hostname allows  
> > > > > the elasticsearch service to start again.
> > > > > 
> > > > > From the above error(not implemented), is it possible that the current  
> > > > > stable elasticsearch release does not support your recommendation and I  
> > > > > need to maybe install an unstable version?
> > > > > 
> > > > > Thx,  
> > > > > Tony
> > > > > 
> > > > > On Sunday, December 22, 2013 4:53:48 PM UTC-8, Karol Gwaj wrote:
> > > > > 
> > > > > > Take a look at default elasticsearch.yml:  
> > > > > > [https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml](https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml)  
> > > > > > especially this part:
> > > > > > 
> > > > > > # Any element in the configuration can be replaced with environment variables
> > > > > > 
> > > > > > # by placing them in ${...} notation. For example:
> > > > > > 
> > > > > > # 
> > > > > > 
> > > > > > # node.rack: ${RACK\_ENV\_VAR}
> > > > > > 
> > > > > > so for example to accomplish this using environment variables:
> > > > > > 
> > > > > > - edit elasticsearch.yml:  
> > > > > > node.name: ${NAME}
> > > > > > 
> > > > > > - create custom bash script:  
> > > > > > #!/bin/bash
> > > > > > 
> > > > > > instead of creating custom bash script for starting elasticsearch you can modify default elasticsearch startup script (bin/elasticsearch) by adding _export NAME=$HOSTNAME_ at the begining of the script
> > > > > > 
> > > > > > On Sunday, December 22, 2013 9:41:13 PM UTC, Tony Su wrote:
> > > > > > 
> > > > > > > Thx jorg, unfortunately your suggestions only configure actual  
> > > > > > > strings, like my original example I'm hoping to automatically retrieve and  
> > > > > > > insert the hostname of the machine. BTW if your suggestion is used in a  
> > > > > > > config I've determined the "./bin/elasticsearch" should be omitted.
> > > > > > > 
> > > > > > > Karol,  
> > > > > > > That looks closer to what I'm looking for but I'm uncertain if the  
> > > > > > > variable can be setup at the beginning of the config file or can somehow be  
> > > > > > > run as part of the ES\_JAVA\_OPTS entry. Or, should the variable be setup as  
> > > > > > > a variable when defining java variables, eg in a profile? I'm also  
> > > > > > > surprised by your use of angle brackets, should they be used as you  
> > > > > > > describe or do they only represent a general grouping of the statement?
> > > > > > > 
> > > > > > > Thx,  
> > > > > > > Tony

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4eb1e5cf-cf70-4c39-a1d9-5d426c75f224%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4eb1e5cf-cf70-4c39-a1d9-5d426c75f224%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:58am UTC](https://discuss.elastic.co/t/possible-to-make-es-node-name-same-as-hostname/14988/18 "2017-07-06T01:58:57Z")

</div>


