无法重新启动elasticsearch

时间:2016-09-01 09:47:59

标签: ubuntu elasticsearch

我在带有ubuntu版本14.04的虚拟机上安装了elasticsearch版本2.3.3。我尝试重新启动elasticsearch服务,但在重新启动后,我使用sudo service elasticsearch status检查了状态,并返回* elasticsearch is not running。当我尝试使用sudo service elasticsearch start启动时,它会返回* Starting Elasticsearch Server,但检查状态后会发现它没有运行。

我尝试通过输入/usr/share/elasticsearch/bin/elasticsearch(这是二进制文件的路径)手动启动它,但在开始时我收到以下错误:

Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
    at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:97)
    at java.nio.file.Files.readAttributes(Files.java:1686)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:109)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
    at java.nio.file.Files.walkFileTree(Files.java:2602)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

错误告诉它无法找到日志记录配置,因此我通过创建符号链接来遵循https://github.com/elastic/ansible-elasticsearch/issues/58中的建议: sudo ln -s /etc/elasticsearch/ /usr/share/elasticsearch/config

之后,当通过/usr/share/elasticsearch/bin/elasticsearch进行弹性搜索时,我收到以下错误:

Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: AccessDeniedException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/config
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:426)
    at java.nio.file.Files.newDirectoryStream(Files.java:413)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:179)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
    at java.nio.file.Files.walkFileTree(Files.java:2602)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

以root用户身份(sudo /usr/share/elasticsearch/bin/elasticsearch)时,我收到以下错误:

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:270)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

这不是我第一次遇到这个问题。我在另一个虚拟机上面临完全相同的问题(第一个例外 - 未找到日志记录配置)并试图通过创建路径/usr/share/elasticsearch/config并将配置文件(elasticsearch.yml和logging.yml)复制到它。之后我又面临第二个问题(以普通用户身份运行 - 拒绝访问并且不允许以root身份运行。)

有人对这个问题有所了解吗?任何帮助都会受到欢迎!

2 个答案:

答案 0 :(得分:1)

您是否尝试过以下操作:

1)创建目录

$ mkdir -p /usr/share/elasticsearch/config/scripts

2)复制日志和配置文件

$ cp /etc/elasticsearch/elasticsearch.yml /user/share/elasticshare/config
$ cp /etc/elasticsearch/logging.yml /user/share/elasticshare/config

3)更改权限或更改这些文件的所有权。

$ sudo chmod g+rwx /usr/share/elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/logging.yml 
$ sudo chmod o+rwx /usr/share/elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/logging.yml

答案 1 :(得分:0)

对于我来说,以下链接有所帮助:

ln -s /etc/elasticsearch/ /usr/share/elasticsearch/config