Startup Error: Can not run elasticsearch as root

Hello,

i am running my Camunda Engine on an VM Ubuntu Server with OpenJDK 11 installed.
image

Now i am trying to start Camunda Optimize with the command
sudo ./optimize-demo.sh

But i always get this as response:
image

The log file says:
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2020-09-28T05:30:24,351][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [swpkss20] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.0.0.jar:7.0.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.0.0.jar:7.0.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.0.0.jar:7.0.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:102) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:169) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.0.0.jar:7.0.0]
… 6 more

The user i am logged in with is not root, but has root permissions with sudo.

Does anyone have an idea what can cause this error and how to solve this? When i start camunda optimize on my local machine everything works just finde.

Thank you!

Kind regards.

@LowkiGG, As per ES code:

So by enabling the property es.insecure.allow.root you can run ES as root user.

bin/elasticsearch -Des.insecure.allow.root=true

@aravindhrs Thank you for your help!

It seems like i dont get the right place to enable this property.
I found a /bin/elasticsearch in camunda-optimize-3.1.0-demo/elasticsearch/elasticsearch-7.0.0.

I added the property in this way in the /bin/elasticsearch file:

But this does not work. I still get the same error.
Can you please tell me where i have to enable it correctly?

Thank you!

No try with enabling this worked. But the solution for me was to take the ownership of this folder with my user, to set the JAVA_HOME anf PATH Variable and to do ./elasticsearch -d within the bin folder of elasticsearch.

It works now.

Thanks for your Help!