How to correctly use variables in the elasticsearch.yml file in Ubuntu

Hi All:
In the /etc/elasticsearch/elasticsearch.yml file. I set the cluster.name as following.
cluster.name: ${CLUSTER_NAME}

And since it's ubuntu, I add
CLUSTER_NAME=ess01
to the end of /etc/default/elasticsearch file.

But when I try to
sudo -i service elasticsearch start

I received the following exception:

  • Starting Elasticsearch Server
    Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'CLUSTER_NAME'
    at org.elasticsearch.common.settings.PropertyPlaceholder.parseStringValue(PropertyPlaceholder.java:116)
    at org.elasticsearch.common.settings.PropertyPlaceholder.replacePlaceholders(PropertyPlaceholder.java:69)
    at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1096)
    at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1056)
    at org.elasticsearch.node.InternalSettingsPreparer.initializeSettings(InternalSettingsPreparer.java:136)
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:115)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:72)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122)
    at org.elasticsearch.cli.Command.main(Command.java:88)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)

Thanks for your help.

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