3

I am trying to run Elasticsearch 5.2.1 in my linux machine which I am the root user of it.

When I tried to execute the Elasticsearch. I am getting the following error,

[2017-03-15T03:26:18,976][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [elk_data1] 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:125) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.2.1.jar:5.2.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:203) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.1.jar:5.2.1]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.1.jar:5.2.1]
        ... 6 more

I tried this way also bin/elasticsearch -Des.insecure.allow.root=true but no luck.

Thanks in advance

Mangoski
  • 2,058
  • 5
  • 25
  • 43
  • It's a **bad** idea so they rightfully decided to make it impossible. Get over it and run ES as a regular user. It's not so that because you are root you have to run everything as root, quite the contrary. – fvu Mar 15 '17 at 10:34

3 Answers3

4

Actually the possibility to run as root has been removed since Elasticsearch 5.0, as mentioned in that issue and here.

If you really want to run as root (I guess you are aware it is not the best idea), I would suggest checking out the source code from github, and modify that specific line, then rebuild the whole project.

Adonis
  • 4,670
  • 3
  • 37
  • 57
0

See this Pull request:Remove allow running as root - GitHub

Sine 2 Jun 2016, you could not run elasticsearch as root unless rebuilding the elasticsearch.

Reference files: elasticsearch/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

k8890
  • 31
  • 4
0

I faced the same error, in my case I used package-manager (dpkg) to install elasticsearch and I were trying to run it directly from elasticsearch's bin directory but it had to be started as service using following command

systemctl start elasticsearch.service
Danish ALI
  • 65
  • 1
  • 9