Possible to make ES Node Name same as Hostname?

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.
To view this discussion on the web visit 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.

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.
To view this discussion on the web visit 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.

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.
To view this discussion on the web visit 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.

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.
To view this discussion on the web visit 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.

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.
To view this discussion on the web visit 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.

Take a look at default 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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.

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/: ${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
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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.

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.
To view this discussion on the web visit 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.

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.
To view this discussion on the web visit 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.

Note, if you are using systemd, you must set environment vars with
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFezypW80PVubmCMp7WnrCaLqqHgdo9F-XxP0aEUPW0Qw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

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/: ${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
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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.

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

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.
To view this discussion on the web visit 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.

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
[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/: ${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
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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.

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
[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/: ${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
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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.

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
[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/: ${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
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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.

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 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.
To view this discussion on the web visit 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.

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
[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/: ${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
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

    create NAME environment variable

    export NAME=$HOSTNAME

    start search node

    /path/to/elasticsearch/bin/elasticsearch

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.
To view this discussion on the web visit 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.