ES_PATH_CONF problem

I've seen several topics about this but none really solved my problem.
I need to change Elasticsearch config path so I created override.conf in /etc/systemd/system/elasticsearch.service.d/ with the following lines:

Environment=ES_HOME={{ service_home_directory }}
Environment=ES_PATH_CONF={{ service_conf_directory }}
Environment=WORK_DIR={{ service_tmp_directory }}
Environment=DATA_DIR={{ service_data_directory }}
Environment=LOG_DIR={{ service_log_directory }}
Environment=PID_DIR={{ service_systemd_directory }}
WorkingDirectory={{ service_home_directory }}

ExecStart={{ service_home_directory }}/bin/elasticsearch -p ${PID_DIR}/

Removing the --quiet from the exec command worked, changing PID_DIR too, but for other variables the process uses values set in /etc/sysconfig/elasticsearch, nothing is overriden.
Did I miss something or do something wrong? I think the solution is very simple but I just can't find it...

Edit: if I check systemctl show elasticsearch.service I do have the correct environment variables (ES_PATH_CONF, WORK_DIR, LOG_DIR, DATA_DIR) but if in the executed process the options are not right:

elastic+ 59979  3.9 15.9 3684404 1276456 ?     Ssl  14:50   0:26 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/elasticsearch/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=rpm -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /path/to/pid/file

Those JVM options are not what I have in my jvm.options, so I think the problem really is that the ES_PATH_CONF isn't used/overriden.

I managed to make it work by commenting out the line defining ES_PATH_CONF in /etc/sysconfig/elasticsearch.
I won't mark this as solved as this isn't a real solution for me. If someone could at least tell me why ES_PATH_CONF in systemd doesn't override the sysconfig file, that would be great.

This is a known issue, but fixing it is a little tricky. See

Thanks for that link.
Although, it doesn't seem to be the same issue. The issue you linked is about not being able to change ES_ENV_FILE. That wouldn't be a problem for me if the environment variables set in this file were overriden by elasticsearch.service.d/elasticsearch.conf. But the answer is indeed a solution to my problem, and that's the only solution I found too.

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