elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.15k stars 24.84k forks source link

ElasticSearch will always start using the /etc/sysconfig/elasticsearch environment file even when a different path is specified #28619

Open linuxcomputergeek opened 6 years ago

linuxcomputergeek commented 6 years ago

Elasticsearch version (bin/elasticsearch --version): ElasticSearch 6.1.2

Plugins installed: [ searchguard]

JVM version (java -version): Java(TM) SE Runtime Environment (build 1.8.0_112-b15)

OS version (uname -a if on a Unix-like system): RHEL 6.8/7.2

Description of the problem including expected versus actual behavior:

After installing the RPM package of ElasticSearch, for multiple node configurations, modifying the system.d file's EnvironmentFile variable and init.d's ES_ENV_FILE variable to point to a different location than '/etc/sysconfig/elasticsearch' will continue to load the default /etc/sysconfig/elasticsearch if the file is present. Removing the file /etc/sysconfig/elasticsearch fixes the issue but it would appear somewhere in the init script of ES it checks to see if /etc/sysconfig/elasticsearch is present and loads that file regardless of what is actually set for the EnvironmentFile or ES_ENV_FILE

This was more prevalent on our RHEL 6.8 servers on init.d than it was on our RHEL 7.2 servers running system.d

JnuLuX commented 6 years ago

I also encountered the same problem on elasticsearch version 6.2.4(CentOS 7) when I run multiple es nodes on the same server,after read the scripts under $ES_HOME/bin, the code in $ES_HOME/bin/elasticsearch-env may related to this issue. Details shown as follows: On line 70 of elasticsearch-env: source /etc/sysconfig/elasticsearch,comment this line(or remove /etc/sysconfig/elasticsearch) and everything goes well except each time when installing plugins you need to specify ES_PATH_CONF manually first.

u238 commented 6 years ago

Hi, any news about this?

hartfordfive commented 6 years ago

Any updates on this? In my case, it's a bit problematic as I'm using Elasticsearch v6.1.1 and I'm trying to run multiple instances of the process on the same server.

siddharthgoel88 commented 6 years ago

Hey @jasontedor . Is this issue planned to be fixed in upcoming releases soon? It is becoming a bit painful because only RPMs seems to have this inconsistent behavior :(

ismaelpuerto commented 5 years ago

The workaround: you can edit the file elasticsearch-env and comment the line: source /etc/sysconfig/elasticsearch

siddharthgoel88 commented 5 years ago

Is this issue planned to fixed in the coming releases?

eppesuig commented 5 years ago

I found the same problem when upgrading from 6.6.0 to 6.8.1 on an Ubuntu 16.04. On Ubuntu the standard configuration is read from /etc/default/elasticsearch instead of /etc/sysconfig/elasticsearch, but the issue is really the same.

As a solution I used the variable ES_PATH_CONF, set in systemd service file, as a flag for skipping the default sourcing. This is a patch:

--- /usr/share/elasticsearch/bin/elasticsearch-env.orig 2019-07-05 18:03:48.228665978 +0200
+++ /usr/share/elasticsearch/bin/elasticsearch-env  2019-07-05 18:00:15.804072022 +0200
@@ -68,7 +68,11 @@

 export HOSTNAME=$HOSTNAME

-source /etc/default/elasticsearch
+# Give priority of any variable initialized by systemd unit and already in the environment
+if [ -z "$ES_PATH_CONF" ]
+then
+  source /etc/default/elasticsearch
+fi

 if [ -z "$ES_PATH_CONF" ]; then
   echo "ES_PATH_CONF must be set to the configuration path"

Bye, Giuseppe

hostalp commented 4 years ago

Please fix this finally, it's an easy fix in the /usr/share/elasticsearch/bin/elasticsearch-env file.

h0lzi commented 3 years ago

I hit this problem today. Also. Took me while to figure this out. It is an easy fix and it would be nice if this can be fixed soon.