Elasticsearch does not load ES_PATH_CONF or any values that are present in sysconfig

Hi,

ES version: 8.3.3
OS: CENTOS 8

We are using packages to distribute our config files in custom directory for the ES service. We can't replace /etc/sysconfig/elasticsearch, because it is owned by the elasticsearch package.

I've noticed similar issues reported, but nothing was done. The main reason this happens is because in /usr/share/elasticsearch/bin/elasticsearch-env we always source /etc/sysconfig/elasticsearch. This leads that ES_PATH_CONF always points to /etc/elasticsearch.

Regards,
Stan

2 Likes

I have the same problem as you. Any ideas how to fix it?

This is expected.

If you installed using the .rpm package you will need to edit the file /etc/sysconfig/elasticsearch to change the value of ES_PATH_CONF, this is documented here.

For the package distributions, the config directory location defaults to /etc/elasticsearch . The location of the config directory can also be changed via the ES_PATH_CONF environment variable, but note that setting this in your shell is not sufficient. Instead, this variable is sourced from /etc/default/elasticsearch (for the Debian package) and /etc/sysconfig/elasticsearch (for the RPM package). You will need to edit the ES_PATH_CONF=/etc/elasticsearch entry in one of these files accordingly to change the config directory location.

This comes from the service file that has this line:

EnvironmentFile=-/etc/sysconfig/elasticsearch

So, to change the value of ES_PATH_CONF while using the package distribution you will need to edit the elasticsearch file inside /etc/sysconfig or edit the /usr/lib/systemd/system/elasticsearch.service systemd service file.

You can also create a different systemd service file and use it to start your elasticsearch service.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.