Elasticsearch部署异常Permission denied

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch部署异常Permission denied相关的知识,希望对你有一定的参考价值。

异常描述

  在Linux上部署ElasticSearch时抛出了一个异常如下:

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /usr/local/elasticsearch/logs/elasticsearch.log
        at java.io.FileOutputStream.open(Native Method)

        at java.io.FileOutputStream.<init>(FileOutputStream.java:221)

        at java.io.FileOutputStream.<init>(FileOutputStream.java:142)

        at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)

        at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)

        at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)

        at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)

        at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)

        at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)

        at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)

        at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)

        at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)

        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)

        at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)

        at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)

        at org.elasticsearch.bootstrap.Bootstrap.setupLogging(Bootstrap.java:204)

        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:258)

        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

  以为自己权限不够,使用sudo运行,仍旧抛出如下错误:

Exception in thread "main" java.lang.RuntimeException: don‘t run elasticsearch as root.
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)

        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)

        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)

        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

Refer to the log for complete error details.

解决方案

  将ElasticSearch的安装目录及其子目录改为另外一个非root账户,如:

sudo chown -R guest elasticsearch-2.4.0
sudo chgrp -R guest elasticsearch-2.4.0

异常原因

  由于ElasticSearch可以接收用户的脚本并执行,处于安全性考虑,建议创建一个单独的用户来运行ElasticSearch。

 

以上是关于Elasticsearch部署异常Permission denied的主要内容,如果未能解决你的问题,请参考以下文章

INSTALL_FAILED_DUPLICATE_PERMISSION 与三星 Galaxy S8

elasticsearch集群分片达到最大引发的问题

使用 Appium 在三星 Galaxy S6 上安装 Yahoo Mail apk 时出现 INSTALL_FAILED_DUPLICATE_PERMISSION 错误

Mac下通过Docker安装ElasticSearch集群

Elasticsearch 插件 ThreadPermission 安全异常

ElasticSearch异常错误