如何在linux机器上以root用户身份运行Elasticsearch 5.2.1

时间:2017-03-15 10:30:51

标签: linux elasticsearch elasticsearch-plugin

我正在尝试在我的linux机器上运行Elasticsearch 5.2.1,我是它的root用户。

当我尝试执行Elasticsearch时。我收到以下错误,

[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

我也尝试过bin/elasticsearch -Des.insecure.allow.root=true,但没有运气。

提前致谢

3 个答案:

答案 0 :(得分:4)

实际上,自从issuehere中提到Elasticsearch 5.0以来,以root身份运行的可能性已被删除。

如果你真的想以root身份运行(我想你知道这不是最好的主意),我建议你从github中查看源代码,然后修改specific line,然后重建整个项目

答案 1 :(得分:0)

请参阅此拉取请求:Remove allow running as root - GitHub

2016年6月2日,除非重建弹性搜索,否则无法以root身份运行elasticsearch。

参考文件: elasticsearch/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

答案 2 :(得分:0)

我遇到了同样的错误,在我的情况下,我使用包管理器 (dpkg) 来安装 elasticsearch,我试图直接从 elasticsearch 的 bin 目录运行它,但它必须使用以下命令作为服务启动

systemctl start elasticsearch.service